New collectibles - Ammo & Health!

Since, in the previous article, we have limited the player to a fixed amount of lasers that he starts with, we need to give him some way of recharging that - and that is where a new power-up comes in!


Add a new collectible power-up to the game, which will refresh the player's ammunition to the maximum. While at it, add another collectible, which will restore the player's life.


First, we need to create prefabs for each collectible - Ammo & Health.

With this done, we need to implement a new method in the ‘Player’ script for each of them.

Ammo - All we need here is to set the current ammo value to the maximum amount and call the update on the UI.

Health - This one is a bit more complicated, as we need to check for different states of the player since we are visualizing the damage.

  • First, we need to increment the health amount. But, these lives can’t exceed the maximum amount of lives.
  • Next, if the player gets healed from 1 or 2 health, the damage visualization needs to be fixed as well.
  • Finally, we need to update the UI with the current life value.

And with that done, we only need to add both of these power-ups into the spawn manager so that they can spawn as well!

Now the player can play a bit more risky, knowing that he might get the precious ammo and even more precious lives back as a collectible!

But that is it for now, thank you for reading and feel free to follow me for more articles - and as always, good luck and see you next time!



Aspiring and eager beginner Unity developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store