【UE4 Tower Defense Game Series】03-Create the first enemy

step

1. Create a new parent class "Chararcter" as the general class of all enemies, named "TotalEnemyCategory"

Create a child blueprint class with "TotalEnemyCategory" as the parent class and name it "Enemy1"

2. Create a new animation blueprint

Select the target bone as "Skeleton_Crossbowman_Skel" and click OK.

 

 Name it "Enemy1_AnimBP"

3. Create a new blending space 1D for blending animation

 Pick the same skeleton

 Name it "Enemy1_BlendSpace1D"

 Open "Enemy1_BlendSpace1D" and place the standing animation on the far left

Place the running animation on the far right

 At this point, move the preview point and you can see that as the value of the abscissa increases, the animation gradually transitions from standing to running.

 The maximum value of the abscissa in the hybrid space 1D is 100, which means that the character will become running when the speed reaches 100, but in the blueprint "Enemy1" we can see that the maximum walking speed is 600, so we need Modify the maximum value of the abscissa in the blend space 1D to 600.

 Changed the name of the horizontal coordinate to "Speed"

4. Open the animation blueprint "Enemy1_AnimBP", ready to add animation to Enemy1

Create a new state machine

 Double click to enter the state machine

 Add "Enemy1_BlendSpace1D"

 Double click into "Enemy1_BlendSpace1D"

 It can be seen that whether to walk or run is determined by the speed

 So we create a new floating-point variable to control the speed, so as to control the running animation

 So how to give the speed of Enemy1 to the variable "Speed"? In fact, just set the "Speed" in the event graph.

 5. Open "Enmey1", select the "Mesh" component, and select "Skeleton_Crossbowman" for the skeleton mesh

In the picture above, you can see that the position of the Mesh is a little bit up, and the orientation is wrong, so we need to adjust its Transform. But it is not appropriate to only modify the Transform of Enemy1, because if there are Enemy2 and Enemy3, their Transforms must be modified. So we only need to modify "TotalEnemyCategory" in the parent class of Enemy1.

This is where we can see that there is no problem with the Transform of the subclass "Enemy1" of "TotalEnemyCategory".

 Animation class selection "Enemy1_AnimBP"

 At this point the first enemy "Enemy1" is created

 

Guess you like

Origin blog.csdn.net/ChaoChao66666/article/details/131715652