Creating VFX using animated sprites in Unity

In this article, I will show you how to make visual effects using sprite animation in Unity. For vehicles, how do we show the effects of damage? The easiest way is to show if there is smoke coming out of it. Fortunately, I already have a sequence of sprites that depict smoke in action.

The first thing we need to do is to drag the first frame into the scene and place it where the damage should appear. In this case, I placed it inside the Player GameObject and on the right wing. I’ve also updated the Sorting Layer and Order so that the smoke will be seen in front.

Next, I will rename the GameObject Fire_00000 to Engine_Smoke_Right. While selected, I will select Window->Animation->Animation to open the Animation window and click the Create button to create a new animation.

The name of the animation will be Engine_Smoke_anim and not say Engine_Smoke_Right_anim because we will re-use the animation on the left wing.

Then, we can drag all of the frames to the dope sheet.

When we press Play for testing, we should see that the smoke is animating.

Now that it’s working, we can duplicate Engine_Smoke_Right and name it as Engine_Smoke_Left. Given that, initially the Player is not damaged, we can set this to Inactive initially.

In my Player.cs script, I’ll add these GameObjects as a reference so I can easily activate and deactivate it at will.

[SerializeField]
GameObject _leftEngineHurt;
[SerializeField]
GameObject _rightEngineHurt;

For now, given that the Player has three lives. I will set that if the player has two lives it will enable the _leftEngineHurt and if one life is left, it will enable _rightEngineHurt:

        _lives-=1;
switch (_lives)
{
case 2:
_leftEngineHurt.SetActive(true);
break;
case 1:
_rightEngineHurt.SetActive(true);
break;
}

Finally, on the Player script of the Player, I will add Engine_Smoke_Left and Engine_Smoke_Right to Left Engine Hurt and Right Engine Hurt respectively.

To verify if this works, click Play.

Done!

I love game design and development.