Unity/C# Challenge 27: Health Collectable

Alec Oney
Aug 17, 2021

Challenge: Put in a Health PowerUp in our game.

Having put in an ammo refill powerup, our next step is to make a powerup that refills the health of the player. Similar to the ammo refill, we create a prefab for the powerup, then modify the relevant code in our Powerup and SpawnManager scripts to include the new powerup. The new method for the power up (within the Player Script) should look like:

Where the code related to the engines are copied from the Damage method. In this case, when the player gets the health reset powerup, his lives will go up if they are less than three. Then, if there is any damage sprites playing, they will cease relative to the damage the player currently has:

--

--