Damage VFX using Animated Sprites in Unity

Renato Figueiredo
3 min readDec 8, 2023

Objective: Learn how to set a damage VFX using animated sprites.

Now we are going to create the VFX that will show when the player is hurt.

First we are going to start with creating the effect that will be in the player.

Creating the effect for the wing.

After creating the effect, we are going to animate it, and afterwards we are going to duplicate the effect and place it on the other wing.

Animating our wing, and creating the right wing.

So with both wings created, we have the animation properly set on the player, when he is hurt. So we are going to turn both objects off, this way, we are only going to see such animations, when the player is hurt.

Turning both wing effects off.

In order for us to properly activate these objects, we need to have them set up in our Player script, allowing us to attach these objects to it.

[SerializeField] private GameObject _leftWing, _rightWing;

Creating the variables for our wings objects. We set them as SerializeField so we can attach them properly in the Inspector.

Attaching our wings to our variables in the Inspector.

Now that we have them properly set, we need to know when to activate them. How would we know this ? Well, we already have a method for taking damage, which is called when we are hit by an enemy. We can just add our logic inside this method, so when we are damaged, our wings start burning!

public void TakeDamage()
{
if (_isShieldOn)
{
DeactivateShield();
return;
}

_playerLives--;

if(_playerLives == 2)
_leftWing.SetActive(true);
else if(_playerLives == 1)
_rightWing.SetActive(true);

_uiManager.UpdateLivesDisplay(_playerLives);

if (_playerLives <= 0)
{
_spawnManager.StopSpawning();
Destroy(gameObject);
}
}

When taking damage, our player now will activate our burning wings effect, based on the amount of lives it currently has. When he is damaged the first time (player lives is 2), our left wing will be activated, and when damaged a second time (player lives is 1), our right wing also becomes active.

We can see our wings burning when we are hit by our enemies.

Now when our player is damaged, we can see the effects of the damage on our ship, showing us that we are burning!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response