Importing the Required Assets
Unreal Engine gives users the ability to import a wide range of file types for users to customize their projects. There are several import options that developers can tweak and play around with to match their required settings.
Some common file types that game developers often import are FBX for scenes, meshes, animations (exported from Maya and other similar software), movie files, images (mostly for the user interface), textures, sounds, data in CSV files, and fonts. These files may be obtained from the Epic Marketplace or any other means (such as the internet) and used within the project.
Assets can be imported by dragging and dropping them into the Content
folder, or by clicking the Import
button in the Content Browser
.
Now let's tackle an exercise where we'll learn how to import FBX files and see how this is done.
Exercise 2.03: Importing a Character FBX File
This exercise will focus on importing a 3D model from an FBX file. FBX files are widely used to export and import 3D models, along with their materials, animations, and textures.
The following steps will help you complete this exercise:
- Download the
SK_Mannequin.FBX
,ThirdPersonIdle.FBX
,ThirdPersonRun.FBX
andThirdPersonWalk.FBX
files from theChapter02
->Exercise2.03
->ExerciseFiles
directory, which can be found on GitHub.Note
The
ExerciseFiles
directory can be found on GitHub at the following link: https://packt.live/2IiqTzq. - Open the blank project we created in Exercise 2.01, Creating an Empty C++ Project.
- In the
Content Browser
interface of the project, clickImport
: - Browse to the directory of the files we downloaded in Step 1, select
SK_Mannequin.FBX
, and click on theOpen
button. - Make sure the
Import Animations
button is unchecked and click theImport All
button. You may get a warning here stating thatThere are no smoothing groups
. You can ignore this for now. With that, you have successfully imported a skeletal mesh from an FBX file. Now, we need to import its animations. - Click the
Import
button again, browse to the folder we created in Step 1, and selectThirdPersonIdle.fbx
,ThirdPersonRun.fbx
, andThirdPersonWalk.fbx
. Then click on theOpen
button. - Make sure the skeleton is set to the one you imported in Step 5 and click
Import All
: - Now, you can see the three animations (
ThirdPersonIdle
,ThirdPersonRun
, andThirdPersonWalk
) inside theContent Browser
. - If you double-click on
ThirdPersonIdle
, you'll notice that the left arm is hanging down. This means that there's a retargeting issue. When the animations are imported separately from the skeleton, the Unreal Engine internally maps all the bones from the animation to the skeleton but sometimes that results in a glitch. We're now going to resolve this glitch. - Open the
SK_Mannequin
Skeletal Mesh and open theSkeleton Tree
tab if not open previously. - Under
Options
enable theShow Retargeting Options
checkbox. - Now inside the skeleton tree, reduce the
spine_01
,thigh_l
andthigh_r
bones to enable better visibility. - Now select the
spine_01
,thigh_l
andthigh_r
bones. Right click on them, and in the menu, click theRecursively Set Translation Retargeting Skeleton
button. This will fix the bone translation issues we encountered before. - Re-open the
ThirdPersonIdle
Animation
to verify the hanging arm has been fixed.
Note
You can locate the complete exercise code files on GitHub in the Chapter02
-> Exercise2.03
-> Ex2.03-Completed.rar
directory by going to the following link: https://packt.live/2U8AScR
After extracting the .rar
file, double-click the .uproject
file. You will see a prompt asking Would you like to rebuild now?
. Click Yes
on that prompt so that it can build the necessary intermediate files, after which it should open the project in Unreal Editor automatically.
By completing this exercise, you've understood how to import assets and, more specifically, imported an FBX skeletal mesh and animation data into your project. This is crucial for the workflows of many game developers as assets are the building blocks of the entire game.
In the next section, we'll be looking at the Unreal core classes for creating a game, how important they are for creating a game or experience, and how to use them inside a project.