Space Shooter Advanced Features (Part 1: Thrusters, Shield Strength, Ammo Count, & Health Collectibles)

Chase Mitchell
4 min readApr 30, 2021

Now that we have the basics of our shooter game implemented, let’s add some more advanced gameplay mechanics to enhance our game.

Thrusters

Let’s give the player a little more control of movement by adding a key for a thruster speed boost. We add a new variable for thrustSpeed to our movement calculation, and set it to 1f by default. While the Left Shift key is held we modify thrust speed to be 1.4f for a 40% speed boost. When the key is released it reverts back to 1.

Shield Strength

We will be adding more difficult enemies to our game, so let’s give our shield a 3 hits before it expires and add a UI element to let our Player know. To do this we create a new shieldHealth variable set to 3 by default. Each time it takes a hit that value is reduced by 1, and if shieldHealth reaches zero our shield breaks. Each time we collect a new shield it resets the value to 3.

We also need to create a new UI element to tell our player how their shield is holding up. We tell the UIManager to update our shield health every time a new shield is collected or when the shield takes a hit:

Shields up!

Ammo Count

Let’s reduce the player temptation to constantly fire bullets without care where they are landing by adding an ammo count. This will incentivize accuracy. We can then add another power up to refresh ammo.

We create a new variable to store our ammo count, then subtract 1 each time we fire, and instruct our UI manager to update the HUD.

Then we create a method to refresh our ammo count (and ammo display) and call this method from the power-ups script.

Ammo Collectible

Now we can add the ammo power up prefab to our spawn manager. I’ve added it twice so there is a higher likelihood of an ammo box spawning, and also reduced the max cooldown between power up spawns from 10 seconds to 8 seconds to speed the spawn rate up a bit.

Health Collectible

Let’s do the same to add a health power up which will add 1 to our player lives. We add the function to our player script which holds our lives variable, increment by 1, then push to the UI manager. Our power up script calls this function on collision.

We also need to update our burning engines to reflect the added life, which we can do by modifying the associated bool variables as follows:

This will reset the visual cues for damage to their intended states.

Voila! That’s it for today’s game updates. I’ll follow up with another guide tomorrow with more features. See ya there!

--

--