Creating a Boss Part 4!

addam davis
3 min readAug 19, 2021

Objective: Adding animations!

If you have followed along with this series, then together we have created a boss that takes several hits to destroy and attacks the player in a new way. To polish the boss battle and to show the player they are making progress we can add damage animations to the boss.

We can make this look better by adding animations. Using the sprite, we used for player damage we can child that sprite to the boss.

If you are using the same sprites as me then you may need to flip your sprites y axis, which is in the inspector under the sprite renderer component.

Now we need to create new animations. We have covered this before, however, select the object and click on the animation tab and create new. Select all the sprites you used to animate and drag them into the animation tab.

Do this for every damage sprite you add to the boss. Once you created an animation for each sprite open the boss enemy script and add a game object for each sprite.

Navigate to the damage method and we need to add 3 if statements. One for when the health is below 75, 50, and 30. Under each if statement you want to set one of the sprites active.

You will need to set the damage objects to not active in the inspector.

To add the destruction animation, we can simply copy the same animation we used on the other enemies. In the inspector select animator and drag in the explosion animation.

In the damage method, you can set the trigger for the animation the same way we’ve done before.

Now when the player battles the boss enemy, they will see damage being done to the boss and an explosive end to the boss.

This is all there is to adding animations to your boss enemy. Now when the player battles the boss enemy, they feel like they are causing damage as well as triggering a giant explosion when the boss is defeated. Never be afraid to experiment with your code, and I’ll see you in the next tutorial!