Damage VFX using Animated Sprites in Unity

DorianBurton6
2 min readOct 3, 2023

--

Now that we can add animated sprites to Unity to use in our scripts, we can add a visual representation for our player damage. To do this, we have a few sprites to represent the damage, and we will set them active as the player’s lives begin to dwindle.

Above are the sprites I will be using to represent the damage to the player. Next, I animated the sprites to give it some extra polish.

Now as our player gets damaged, the engines will combust one at a time as the player loses their lives. Now that I have the sprites and animation, I need to call it in my script to activate once the player has taken damage.

[SerializeField]
private GameObject[] _playerDamage; //0 for left engine, 1 for right engine

public void Damage()
{
_lives -= 1
if(_lives == 2)
{
_playerDamage[0].SetActive(true);
}
else if(_lives == 1)
{
_playerDamage[1].SetActive(true);
}
}

With this method, when the player loses a life, the player damage is set active for each life lost. And after all our lives have been depleted, the player is destroyed. Now we have a visual representation of the lives being depleted and a visual for our player character showing how much damage they have taken.

--

--