Project 1: Space Shooter

A new ammo collectable for the player

Or points if the player hasn’t used any

Eero Saarinen
Jun 24, 2022
The player gains points if no ammo used, or they get max ammo whether or not they used some or all.

Making the new ammo collectable is done exactly the same way as the previous powerups, so no need to go the basics all over again. Another thing to note is that I replaced the “Ammo: “ text of the UI element to the ammo powerup’s sprite.

For the powerup to work I added a new public method AmmoCollected to the player script, which in turn is called from the powerup script once the player has collected the powerup.

This method will check if the player has used any ammo, and if they have, fill the ammo count to full and update the UI element to show this. If the player hasn’t used any ammo, the method will instead award the player hundred points.

The code for the ammo collectible when it is collected.
The logic behind the ammo collectible.

--

--