top of page
Set damage take settings

Now let's put the necessary software to make the enemy take damage.

1- Create animation and Blueprint animation

1- Let's first create 3 movement patterns 1- Receive damage (orchit) 2- Death (orcdeath)
3- orcdeadbody

image.png
Screenshot 2024-09-23 193029.png
Screenshot 2024-09-23 193203.png

2- دعونا ننتقل إلى ملف مصدر الأنيميشن(allnimationsource) ونقوم بوضع جميع الأنيميشن التي أنشأناها للتو

image.png

3- We move to the Blueprint animation, and because we will move from any state to the state of receiving damage (orchit) , there is something we can add called
(jump node) makes us jump from any state with the press of a button. When we click the left mouse button, Jump will appear at the end of the list and we name it damageevent.

4- We exit the jump node state (animation state) that we want to run in the event of moving to the jump node and we call it orcgethit .

5-Inside the orcgethit state we put Play orchit
6- We connect from the orcgethit state to the idle/walk state.
After the enemy takes damage, he will go into an idle state.
7- In the case of transitioning between the orcgethit state and the idle/walk state, we must write in the search box time remaining and it will appear automatically.
time remaining(
orcgethit )
time remaining: is the time remaining until the animation ends, in which we can specify the time remaining until we move from the
orcgethit state to the idle/run state
We set less to get the time left to take damage in the last 0.1 seconds and then move on.
8- We create a new jump event and name it deathevent.
9- We exit the jump node, the animation state that we want to run when moving to the jump node, and we call it orcdeath.
10- Inside the orcdeath state, we put Play orcdeath
11- We create a new animation state and name it (deadbody) and connect it with orcdeath to move from the death state to the corpse.
12- Inside the deadbody state we put Play orcdeadbody

image.png

13- In the event of transition between the orcdeath state and the orcdeadbody state, we must write in the search box time remaining and time remaining ( orcdeath ) will appear automatically.
We set less to get the time remaining for the character to die in the last 0.1 seconds and then move on.

image.png

2- Activate animation in Blueprint

In the previous lesson, we created a point in the character blueprint bp_char called apply damage and made the value of the damage variable 2 (apply damage): it deals damage to any other character.
The type of the variable is float: numbers with intervals that can take a small value (symbolized in green in Unreal)

image.png

Now we will make the enemy take damage from the character we will be playing with and to do that:
1- We have to go to the enemy's blueprint file bp_orc and create an event programmed from Unreal called event AnyDamage
event AnyDamage
: An event that only occurs if the enemy (this actor) receives any damage.

image.png

We will notice that in the AnyDamage event there is a float called ( damage ).
The number we will plug in
will be the damage received and what we have to do now is
1- Create a variable of type (
float ) that holds this value and name it ( orchealth ) and make its value 4 , then call it
2- We create a subtraction point where we will subtract the value of the damage dealt to the enemy with the new value of the enemy's energy ( orchealth ).
Which means that every time the enemy takes any damage, the
orc health value will decrease .
3- We have to set the new value of the enemy's energy (
setorchealth ) after receiving damage ( orchealth ) by summoning him again and connecting it with the AnyDamage event and the sum of the result of the subtraction process between the value of the damage that the enemy is exposed to ( damage ) and the value of the energy ( orchealth ).
4- If the new value of the enemy's energy (
orchealth ) is less than or equal to 0, execute the deathevent animation .
5- If the new value of the enemy's energy (
orc health ) is greater than or equal to 0, execute the damage event animation.

image.png

6- We go to the personal Blueprint page ( bp_orc ), then the details page, write anim , then choose the character’s Blueprint animation (animationbp_orc) and start playing.

image.png

3- Make the enemy stop and we can pass through him

After hitting the enemy, we will find that he dies after receiving 4 hits, but when he dies and moves to the orcdeadbody animation, we will find that he is still moving and does not disappear.
So we have to create software that makes the enemy stop and disappear when he dies, and we can pass through him. To do that:

1- We create a new variable and name it ( orcdead ) of type boolean: a variable that can only take two values, either true or false.
2- We call it (
set ) and put it after the jump point ( deathevent ) and put a check mark

image.png

We have to make the enemy stop moving if the variable we created ( orcdead ) is met.
So we have to go to the handlingmovement event and output a branch after the handling event and make the condition variable orcdead and connect the false condition with the movement software ( add movement input ).

image.png

We will call ( capsule component ) and get out of it set collision profile name
capsule component : is the component that has the property of colliosion with objects.
set collision profile name : Changes the enemy collision type by typing the collision type name.
The collision type will be ( overlap only pawn ).
overlap only pawn: Any pawn character can overlap an enemy when they die .
Information: All the characters you will create will automatically have a collision type of pawn, and we can confirm this by going to the character blueprint, then details, and typing collision.

image.png
image.png
image.png

4-Make the enemy disappear upon death

We will make the enemy disappear upon death after 2 seconds and we can do this very simply by doing the following:
1- We create a delay point and make the time 2s
2- We create a destroy actor point.
destroy actor : destroys the enemy and hides him from the stage permanently

image.png
bottom of page