Objective: Create player damage levels with animated sprites.
Carrying on from the last post with enemy explosions, now it’s time for the player effects. We add the damage sprite to the player wings and position them.
Open the player script and create two global reference variables for the left and right wing damage elements and assign them in the inspector and turn both off as default.
Next go to the TakeDamage method just under where lives get reduced for collisions. Using an if statement to check the lives enable the left damage on two lives remaining and then enable the right damage on one life remaining.
Finally set up the animation for the engine damage. Select the left engine element, open the animator window and create an animation called Engine_Damage_anim. Next on the right engine element add an animator component and assign the animation.
In the next post, we will look at post processing in Unity.