Adding a Health collectable.

Jason Schneider
2 min readSep 7, 2021

Since we have allowed the enemy to shoot and damage the player, maybe we should add a collectable that can heal. In order to accomplish this, we will need to add another case to our powerup script, such as:

Then we need to add this new method to our player script.

If player lives is less than 3, add 1. If either EngineFire is active, deactivate it. Then update the UIManager with the lives count (so lives sprites are updated).

Now we need to create another powerup prefab for the collectable and set its powerupID to 4.

Then, in our SpawnManager; in the Hierarchy; we need to change the Powerups size to 5, and drag in the newly created prefab into Element 4.

Lastly, we need to change the code in our SpawnManager script to:

In order to encompass this new powerup, as one to spawn randomly.

--

--