Phase 1: Ammo Count

Objective: limit the player's ammo to 15 lasers and display information to the player

First I will work on the UI element so I will need a text field to display the ammo count to the player.

With the serialized field attribute I can assign it in the inspector.

Next, I will create a method to update the ammo count on the UI. Also at the start of the game, the ammo count will be 15.

Now we can move on to the player, we will need a variable to store the ammo count.

Next, we will need to reduce the ammo count when each laser is fired and call the UI UpdateAmmo method.

Also in the FireControl method, we set canFire to false when the laser count is less than 1.

Ok now let’s see this in action.

Happy Coding!



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