Create A Parasite Platformer Game In Unreal Engine Part 9: Importing And Animating The Parasite Enemy

Table of Contents

Create A Parasite Platformer Game In Unreal Engine Part 9: Importing And Animating The Parasite Enemy

Reading Time: 15 minutes
Level: Beginner
Version: Unreal Engine 4.26

Help Others Learn Game Development

In part 8 of this tutorial series we coded the logic that will end the game when the PlayerCharacter reaches the level goal or when he collides with the fire obstacle.

We also learned how to work give input control to UI widgets and how to interact with them when we press them.

In this part of the tutorial we are going to import the enemy 3D object and learn about animations in Unreal Engine.

Where To Get Free 3D Characters For Your Game

You can download the assets for this game in the first part of this tutorial series by clicking here.
 
I always add the download files for the assets and the complete project of the tutorial at the very beginning.
 
However, I want to show you where I got the 3D Parasite model that I am using for this tutorial because you can get other high quality 3D characters from that website as well.
 
The website in question is mixamo.com.
 
It’s a website that allows you to use their pre-made 3D models, rig them, animate them, and export them with all the animations and materials and use them in your commercial games completely free.
 
For those of you who don’t know what rigging a 3D model means, it’s basically giving the 3D model a skeleton which will be used to animate and move the 3D model.
 

How To Use Mixamo.com

Head over to mixamo.com and create an account same as how you create an account on any website.
 
When you finish that, at the top left corner where the mixamo icon is, you will notice two buttons:
 
Img 1
The Characters button will open a list of 3D models where you can choose your desired model and the Animations button will open a list of animations that you can apply to your selected 3D model.
 
Click on the Characters button and in the search filter for  parasite and locate the 3D model called Parasite L Starkie:
 
Img 2
When you select the 3D model, in our case the Parasite L Starkie model, you will see a preview of the model appear on the right side:
 
Img 3
The 3D model is previewing in a T pose that’s why you see him spreading his arms to form the shape of the letter T.
 
To download the 3D model click the yellow Download button at the top right corner:
 
Img 4
When you click the Download button a pop up window will appear with the download settings:
 
Img 5

If you click on the Format drop down list you will see different formats in which we can download the 3D model:

Img 6

We are going to select the first one FBX Binary(.fbx). For the Pose leave it at the default T-pose. Click the Download button and choose the download folder for your 3D model.

Now click on the Animations tab and filter for idle:

Img 7

As you can see we have a lot of idle animations at our disposal. We are going to select the first animation from the right side in the second row of this list:

Img 8

When you select the animation it will automatically be applied to the selected 3D model and you can see it action.

You can also zoom in and out in the preview window and move around using the mouse and the WASD keys on your keyboard:

On the right side of the preview you will see the animation that is applied to the 3D model and some of the settings that we can tweak for the animation such as arm space of the 3D model e.g. the arm spread length of the 3D model:
 
As you can see we can change some settings of the animation such as the frame length and the arms spread of the 3D model. For the current animation we are going to leave those values at their default.
 
To download the animation press the same Download button you pressed when we downloaded the 3D model. When you do, a pop up window will appear with the Download Settings:
 
Img 9

The Format settings is going to stay the same e.g. FBX Binary(.fbx), the Frames per Second is 30, Keyframe Reduction is none, as for the Skin, click the drop down list and select the Without Skin option and press the Download button:

Img 10
The Without Skin option will simply download the animation without the materials for the 3D model. We don’t need the materials because they are included with the 3D model that we already downloaded.
 

One thing that I will also mention is that you are not obligated to use the same idle animation as I did. You can use any idle animation that you find on the website, this will not affect the game in any means.

We also need the running animation so in the search at the top left corner type running, and from the animations list select the first animation from the right in the second row:

Img 11
When you click on it, it will be applied to the 3D model. Since this is an animation where the 3D model moves you will also see the model moving in the preview.
 
If you want the model to stand still while you are previewing the animation you can check the In Place checkbox in the animation settings:
 

The same settings we talked about for the idle can be applied here for the running animation which means you can change the arm spread length of the 3D model.

We can also change the speed of the animation using the Overdrive settings. We didn’t cover it for the idle animation because it would not make much of a difference, but for a fast animation it can be useful to make the animation faster or slower:

For the running animation set the Overdrive settings to 30, and the arm spread length to 65, again you don’t have to use the exact settings as I am or the same animation, you can choose some other animation and other settings.

When you are done, click the Download button and in the Download Settings window use the same settings we did for the idle animation.

For the Skin choose Without Skin and other settings can stay at their defaults and press the Download button.

Importing Assets In Unreal Engine

Since we were using the Starter Content assets we didn’t import any external assets to use for our game.
 
Importing assets is very easy, just drag the desired asset in the Content Browser tab.
 
But before we do that, Right Click -> New Folder to create a new folder under the Content top parent folder and name it Models.
 
If this was a larger game we would create more folders inside the Models folder to group different models in their folders for better organization, but since we have only one 3D model we can also create one folder.
 
First we are going to import the 3D model and then we are going to import the animation.
 
From the folder on your computer where you saved the files we downloaded from mixamo.com, drag the parastie_l_starkie model in the Models folder that you created a moment ago:
 
Img 12
When you do that the FBX Import Options window will appear. What’s important to make sure inside of this window is that the Sekeletal Mesh and Import Mesh checkboxes are checked under the Mesh settings, and that the Import Textures checkbox is checked under the Material settings:
 
Img 13
By default all these options should be checked, but it’s always a good thing to double check.
 
When you are done press the Import All button at the bottom of the FBX Import Options window and wait for Unreal Engine to import the assets.
 
If you encounter any warning messages in the Message Log window you can safely ignore it and close the window as that will not affect the 3D model and our game:
 
Img 14
When the import is done you will see that the 3D model is imported along with the materials and textures:
 
Img 15

Now that we imported the Parasite 3D model we can import its animations.

The reason why we first import the 3D model then we import the animations is that the animations are depended on the 3D model because they need a skeleton of the 3D model for the animation to work.

We can create a separate folder where we would store the animations, but again, since we have only one 3D model in the whole game we can place the model and its animations inside the Models folder.

So now, drag the idle animation inside the Models folder:

Img 16

Same as with importing the 3D model, the FBX Import Options will appear.

You can see that under the Mesh settings the selected skeleton for the idle animation is the parasite_l_starkie_Skeleton which is detected by default because we imported the 3D model first.

For the animation we don’t need to check anything inside the FBX Import Options we can just press Import All button and wait for Unreal Engine to import the animation:

Img 17

Import the running animation by repeating the same process we did for the idle animation.

Making The 3D Parasite Model Visible By Changing The Material Settings

We can preview the 3D model that we imported by opening it in the editor window. Double click on the parasite_l_starkie in the Models folder:

Img 18
When you do that, the model will open in the editor window:
 
Img 19
You will notice that the 3D Parasite model is transparent  meaning we can see through him, which is not the behaviour that we want.
 
To fix this, open the parasitezombie_Material in the editor:
 
Img 20

Inside the Material editor window for the parasitezombie_Material, in the Details tab on the left side under the Material settings, change the Blend mode settings from Translucent to Masked, and when you are done, press the Apply and Save buttons at the top left corner:

If we check out the 3D Parasite model now, we will see that it is not transparent anymore and it is fully visible with all of its textures:

Img 21


Creating The Enemy Blueprint

Before we can animate the Parasite enemy we need to create a Blueprint for it.

Inside the Blueprints folder Right Click -> Blueprint class. Make sure it inherits from the Character class and give the new Blueprint name BP_Parasite_Enemy:

Img 22

Open BP_Parasite_Enemy in Blueprint editor. In the Components tab, select the Mesh component and in the Details tab under Mesh settings select parasite_l_starkie as the Skeletal Mesh:

Img 23

Now you will see the Parasite model inside the BP_Parasite_Enemy editor:

Img 24

You can see that the Parasite mesh is placed above the Capsule component which is used to provide a solid body for the Parasite mesh.

Because of that we are going to edit the Location property of the Parasite mesh. In the Transform property set the following values for the Location:

  • X = 0
  • Y = 0
  • Z = -87

And set the values for the Rotation:

  • X = 0
  • Y = 0
  • Z = 270

We changed the Z rotation value so that the Parasite mesh is facing forward when he is spawned in the game.

Now the Parasite mesh is placed inside the Capsule component:

Img 25


Animations In Unreal Engine

As I already mentioned a few times, if this was a larger game where we have more enemies and we need to animate them all we would create a separate folder to store the animations.

But for this game since we only have one enemy we can save the animations inside the Models folder.

So inside the Models folder Right Click -> Animations -> Blend Space 1D:

Img 26

When you click on Blend Space 1D a new window will open prompting you to select a skeleton of the 3D model that will be used for this animation, in our case parasite_l_starkie_Skeleton:

Img 27

Name the animation Idle_Run_Animation.

If we had more idle and run animations for different enemies I would add the name of the 3D model who is the owner of that animation, for example Idle_Run_Parasite_Animation.

But again, since we only have one enemy we can just name it Idle_Run_Animation.

Now let’s talk about what is actually Blend Space 1 that we created?
 
Blend Space 1 will allow us to use two animations and blend them together based on the parameter that we provide.
 
And with blend, I mean that based on the value of the provided parameter, we will gradually switch from one animation to another.
 
Open the Idle_Run_Animation in the editor by double clicking on it.
 
On the left side you will see two tabs: Skeleton Tree and Asset Details.
 
In the Asset Details tab under Axis settings you will see Horizontal Axis drop down list:
 
Img 28

The Horizontal Axis is going to be the parameter that we will use to blend the idle and running animation.

In the settings of the Horizontal Axis under name type Speed. For the Minimum Axis Value leave it at 0, and for the Maximum Axis Value set it at 375:

Img 29

To make this work, we need to drag the idle and the running animations in the timeline.

Keep in mind, the idle animation goes on the left side and the running animation goes to the right side:

Because this is a Blend Space 1, we can add two animations in the timeline. One on the left side and the other on the right side.

On the left side we added the idle animation and on the right side the running animation.

Which means when the Speed parameter that we set up changes its value, we will shift from idle to running animation.

We can even preview that by using the Green frame icon in the timeline:

The Green Frame icon as I named it, represents the Speed parameter that we created.

When the Speed parameter has a value of 0 the idle animation is being played, when it has a value of 375 the running animation is played.

We also saw that while the Speed value gradually increases, a transition from one animation to another is performed.

Creating The Animation Blueprint

In the example above we changed its value manually by dragging it left and right, but we can also change it via Blueprint code when the movement speed or velocity of the BP_Parasite_Enemy changes in the game, and this is how we are going to animate the Parasite character.
 
For that, we need to create an animation Blueprint. Inside the Models folder Right Click -> Animation -> Animation Blueprint:
 
Img 30

When you do that you will be prompted to select a Target Skeleton. The Target Skeleton is always the skeleton of the 3D model you want to animate.

In our case, you are going to select parasite_l_starkie_Skeleton and press the Ok button to create the animation Blueprint:

Img 31

Give the new Blueprint name BP_Parasite_Animation and open it in the editor.

So far you noticed that all different Blueprints have similar tabs and previews in the editor, be that UI Blueprints or normal Blueprints.

Animation Blueprints is not different so when you open it in the editor this is what you will see:

Img 32


State Machines

Inside the AnimGraph you see the Output Pose node, which is basically the node that will represent the animation.
 
We need to plug in our Idle_Run_Animation in the Output Pose so that it will be player via the Blueprint.
 
To do that, Right Click inside the AnimGraph and filter for state machine in the search:

Img 33

Rename the state machine to Default State by either selecting it and renaming it in the Details tab, or click on the name of the state machine two times until you see a text field where you can rename it:

Img 34

Connect the output from the Default State in the input of the Output Pose, basically connect the two human icons together:

Img 35

Make sure that you hit the Compile and Save button every time you make a change to the animation Blueprint for the change to apply to the Blueprint.

Now what are state machines?

In the simplest way, we put the animations we created, such as Idle_Run_Animation, inside the state machine and we define transitions with conditions that need to be fulfilled for those animations to play.

We can also transition from one state machine to another, and we can also add an animation inside the state machine and make it play without any conditions.

To do this, double click on the Default State machine. Inside, Right Click -> Add State… and rename the new state to Idle / Run:

Img 36
The Entry node is the entry point in the current state machine. We can drag a line from it and connect it to a state, such as the Idle / Run state that we just created:
 
Img 37

This will denote that when the execution enters the Default State machine, it will go where the Entry node is pointing which is the Idle / Run state and it will play the animation we add inside.

To add the animation, double click on the Idle / Run state, and drag the Idle_Run_Animation from the Asset Browser window inside the Idle / Run state:

Img 38

You will notice two things on the Idle_Run_Animation. First it has a Speed parameter to the left side and it has an output on the right side denoted with the human icon:

Img 39
You can already assume that we need to connect the output of the Idle_Run_Animation with the Result input of the Output Animation Pose:
 
Img 40

The Speed parameter is the one we set up for the Horizontal Axis in the Axis Settings inside the Idle_Run_Animation Blueprint:

Img 41
We know that when the value of the Speed parameter changes the animation will transition from idle to running and we saw that in action when we manually changed the Speed parameter’s value.
 
I also mentioned that we can change the Speed parameter’s value inside the Blueprint. To do that, inside the BP_Parasite_Animation Blueprint we need to create a new float variable and name it Speed:
 
Img 42
Now drag the Speed variable inside the graph and select the Getter to get the value of the Speed variable:
 
Img 43

And the last step is to plug in the Speed variable in the Speed parameter of the Idle_Run_Animation node:

Img 44
Make sure that you Compile and Save the new changes and when you do, you will notice that the Parasite model is now being animated in the preview at the top left corner:
 
Img 45


Navigating Inside The Animation Blueprint

Before we proceed further, I want to show you how can you navigate in the animation Blueprint because we have all of these state nodes and every time you click on one you enter inside of that state node, so we need to know how can we go back:
 

Other navigation inside the animation Blueprint is the same as in other Blueprints, but the state nodes are specific for the animation Blueprint so we had to learn how to navigate to and back from them.

Applying The Animation Blueprint To The Enemy Blueprint

To animate the Parasite enemy, we need to specify that the BP_Parasite_Enemy Blueprint should use the animation Blueprint that we just created.

To do that, go inside the BP_Parasite_Enemy Blueprint and select the Mesh in the Components tab.

When you do that, inside the Details tab you will see the Animation settings:

Img 46
In the Animation settings, click on the drop down list under the Anim class and filter for BP_Parasite_Animation:
 
Img 47
When you select the animation Blueprint that we created you will notice that the Parasite model is not in his T pose anymore instead he is being animated with the help of our BP_Parasite_Animation:
 
Img 48
Before we wrap this part of the tutorial drag the BP_Parasite_Enemy inside the level. Rename it to Enemy and set its Location values to:
 
  • X = -9858
  • Y = -855
  • Z = 93
Img 49

You can also create a new folder under the Level folder in the World Outliner, name it Enemies and drag the Enemy in that folder.

Where To Go From Here

In this tutorial we learned how to use animations inside Unreal Engine and we created an animation Blueprint for the Parasite enemy.
 
In the next part of this tutorial series titled Enemy AI Behaviour And Wrapping Up Our Game you will learn the basics of creating AI behaviours in Unreal Engine and we will wrap up our game.
 

Leave a Comment