Last article we created a new Explosion to go with our destruction of an Asteroid that would start our Game.
In this section we’ll spruce up our Player a bit — giving them a Thruster, and also implementing some visual cues on the Player to check their Health amount!
In creating the Player’s Thrusters, it will be a permanent Child of the Player object. This ensures it follows the Player.
So, we’ll create the Thruster Game Object and attach it to the Player:
Then we can position it accordingly to our Player, and scale it to what we deem correct:
With these Thrusters, I’m fortunate to have additional Sprites I can use to animate it, so I will do so by creating a new Animation while having the Thrusters selected in the Hierarchy. The Animation looks like this:
And this is how it appears when we’re flying (swimming? zooming?) through Space:
Player Damaged VFX
Now we’ll create some damage indicators on our Player that correlate with how much Health they have left!
First we’ll create the VFX as a child to the Player so that we can simply enable/disable them when needed:
Then we’ll position these new VFX to some appropriate places:
Make sure to change the Sorting Layer and Order in Layer of these new VFX as well!
Next create an Animation for the Engine Failures (if you have the extra Sprites), and link the Engine_Failure animation clip the the Animator Controllers of each Engine:
Now test if the Damage indicators look alright and operate with their animations:
Next we’ll jump into our Player script and create new references to our Engine_Failure damage indicators:
- When creating variables or references inside a script, if two or more are of like kinds, you can create multiple variables/references in one line. Separating them with a comma!
Now into our DamagePlayer() function. We’ll activate one Damage Indicator per life lost:
And finally link our Engine_Failures in the Player’s Inspector:
Perfect! Now our Player has some more visual cues on their Health, and they look good doing it!
In the next article we’ll begin touching more on visual enhancement. This time in the form of Post Processing volumes and layers!