Platformer: Death Animation


In this brief article I cover how to add a death animation with the use of a status bar. The status bar represents the toxic levels the player has been exposed to and when it is fill, the player will die.


Found a death animation on Mixamo and imported into Unity. Please take a look at some of my earlier articles on how to important animations into Unity from Mixamo.

We are going to have this Dying animation transition from Any State. This makes the most sense because if the toxicity levels are at the maximum while climbing, it would not make sense for the player to continue to climb then die. Later, I will have to add different dying animations to match what the player was doing at the time of death.

This transition will happen using a Trigger parameter called “Dead”.

When adjusting the animation setting, it is helpful to be in Play mode and have the Animator window with the Game window visible. You can then adjust the animation settings, use the trigger parameter to trigger the animation so you can how it looks in the game. You can quickly iterate through the animation settings until you found what looks the best.


The Player script has access to the Animator, so we will need to trigger the “Dead” animation parameter through this script. But, the Toxicity Bar (Status Bar) script knows when it is has reach the maximum value, so we will create a public method “PlayerDeath” that will trigger the “Dead” animation annd we can call it form the Toxicity Bar script.

We will get a handle on the Player script from the ToxicityBar script by declaring a Player class variable with a Serialized Field attribute, so we can assign it in the Inspector. Make sure to perform a Null check to ensure you have a handle of the Player.

We have a method that is adding a certain amount to the Status Bar (Toxicity Bar) and this is where we want to check to see if the current toxicity value is either equal to or greater than the maximum toxicity value (this represents a full status bar). When this happens, we want to call the PlayerDeath method from the Player.


I am going to have implement different conditions to trigger different death animations depending if the player is climbing, jumping, or another action when they die so stay tuned. Cheers!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store