UI — Improved Ammo Display

Cap the maximum ammo

Jean-Noel Seneque
2 min readJun 28, 2021

Objective: Add the maximum ammo to the UI and cap the ammo collected

In this article, we will make a slight improvement where we will let the player know the maximum ammo the ship can carry.

UI Improvement

In the AmmoUI, create new textboxes (or duplicated the AmmoText which I had renamed to CurrentAmmo) and position them. For this first phase, I simply hardcoded a 50 as the text for the Max Amount UI Textbox. Maybe at a later stage, we will introduce changes in the maximum amount and update the UI.

Implement the code

In the PlayerShoot script, add a variable to store the maximum ammo amount.

The following change to the UpdateAmmo method to cap the ammo to the maximum amount.

If you enjoyed reading this article give me a Clap, also if you would like to see more, “Follow” me, so you may be notified of future releases. You may also send me a message if you need any further help.



Jean-Noel Seneque

A Data & Analytics Consultant who is expanding into developing experiences in XR, Enterprise and Gaming space using Unity www.jeannoelseneque.com