Damage VFX using Animated Sprites in Unity
For today’s article, I’ll be going over how I added damage Visual Effects onto the ship’s engines using Unity’s Animation system.
Setting up the Player Game Object
In the Player game object within the Hierarchy window, I placed 2 child game objects named Left_Engine and Right_Engine. Each engine has the following components attached:
Next, I dragged and dropped all the animation frames for when one of the engines from the player’s ship gets damaged onto the Animation dope sheet window. Here, I made sure that the engine game object in the hierarchy is selected and that an animation file is created to store the animation frames for the damage VFX:
Lastly, I disabled the engine game objects so that they do not appear on the ship when we first play the game:
Adding Engines into the Player Script
The behavior I wanted to achieve when the Player Ship gets damaged is to pick a random side to enable one of the damaged engine VFX. I achieve this by implementing the following below inside of the Damage()
function:
Final Result
Thanks for reading :)