Toggling Damage Animation

Linking the Damage state when our enemy gets hit

Simon Truong
3 min readDec 10, 2021

It is now time to link everything together, the Animation, the Hit collision and the Health depletion.

Toggling the Damage Animation:

In the Animator window we are going to make sure that the Hit animation is transitioned from the “Any State”. Then we are going to transition to the Idle Animation (later on we will make this transition go towards the Fight Animation).

Then in the Skeleton script where the Damage Method is being applied, we are going to toggle the animation trigger. Since the parent Enemy script already has access to the Animation component we can just call the handler straight from the skeleton script.

If we test this out right now, you will noticed that the Skeleton does play the damage animation when being collided with the sword, the skeleton doesn’t stop moving. This is because we have nothing to toggle the parent enemy movement script to pause.

Skeleton doesn’t stop moving even when hit.

In the parent Enemy Script, we are going to first create a protected bool that will be by default set to “false”. This will set the condition to pause the skeleton movement.

In the movement method we are going to create the if statement that will only allow movement when the bool is set to false. By proxy when the bool is set to true, the skeleton should stop moving in place.

Finally back to the skeleton script, we are going to toggle the bool and set it to true when it is being hit.

The end result is the skeleton pausing movement when being hit.



Simon Truong

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.