Road TO Dev — Unlimited Ammo? Too easy!

Rob Smith
2 min readMay 28, 2021

So our player has infinite ammo at this point and that’s just too easy so to help add difficulty let’s give them limited ammo. This will require a couple of variables. Of course our trusty bool to check if we have ammo and an int for our ammo count.

Before we fire we will want to check and make sure we have ammo.

Then once we click to fire we want to lower the ammo count and check to make sure we aren’t out of ammo after.

For the sake of testing I recommend serializing the ammocount variable that way we can see it go down and make sure we stop right when it hits 0. Now we can test to see if it’s working. Also you may want to increase the fire rate to test this or lower the ammo count amount.

--

--

Rob Smith

Hi there! I am currently on the path to learn how to become a unity developer and will be documenting my journey as best as I can here. Thanks for looking!