Ammo Count

Matthew Bartosh
2 min readSep 13, 2022

Today my objective is to set an ammo count and display it.

I’ll set up a _currentAmmo int and _outOfAmmo audioclip in my Player to start with.

Then I’ll update the FireLaser() method to subtract one from the current ammo if TripleShot isn’t active, since I want to give the player the ability to ‘spam’ that during the short window it’s active. I’ll also call UpdateAmmo(_currentAmmo) in the UI Manager to update the on-screen text.

Then I’m changing the GetKeyDown if-then statement to state that if my ammo is greater than 0 OR TripleShot is active, it’ll call FireLaser(), otherwise it’ll play my Out of Ammo sound.

Now on to the UI Manager, adding ammo text and creating the UpdateAmmo method.

Here it is in action! (Also a little spoiler to the next article where I create the ammo pickup.)

Obviously, you can’t hear the sound in the gif but it’s there! That’s it for this article!

--

--