Damage VFX using Animated Sprites in Unity
Objective: Display when the player has been damaged by using visual effects in Unity.
Go to the Player_Hurt folder in the project Assets file and drag the Fire_00000 sprite to the Hierarchy and nest it within the Player. Change its scale back to 1,1,1. Change the sprite’s Sorting Layer to Foreground and the Order in Layer to 1.
Change the sprite’s name to ‘Right_Engine’, duplicate it and move the duplicated sprite to the left and rename it to ‘Left_Engine’. Deactivate the sprites so that they don’t show.
In the Player script, initialize the Right and Left engine GameObjects. Assign them in the Inspector and create logic to enable them. If Lives is equal to 2, enable the Left Engine. If Lives is equal to 1, enable the Right Engine. Save the script and animate the Right and Left engine GameObjects by using the sprites in the Player_Hurt folder in the project Assets file. Create a new animation and name it ‘Engine_Failure_anim’. Rename the Right_Engine Animation Controller to ‘Engine_Failure’. Assign Engine_Failure to both Right and Left engine Animator Controller components.