The Maximum Ammo Amount Limit- Game Dev Series 41

Objective: Create a maximum ammo limit to Player.

Set a maximum limit to ammo is quite fair to game design. You either give the player a few ammo, or set a max limit to them. As this kind of space shooter game, an ammo maximum limit would be reasonable.

To set a maximum ammo limit, we will need to adjust Player and UIManager these 2 scripts.


Create another integer variable to storage maximum ammo with SerializeField. This would make it easier if we want to change the number of maximum later.

In the Update() method, add _laserMaxCounts variable to UpdateAmmo(). We will make the UI display these 2 number at the same time.

Then go to AmmoCollected() method. Create another if statement to prevent the ammo is added over the maximum limit.
And also update the UI again at the bottom.

That should be done with Player script.


With UI is quite easy. In the UpdateAmmo() method, add another integer that it will receive from Player script.

Then we can just update the UI with these 2 integers.

Now you have the maximum ammo limit!




A passionate gamer whose goal is to work in video game development.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Gameplay Journal #8

Atommix: A synthesis of art, fun and science

Gravity Rush: Gem Collection and Mechanic Reinforcement


Adding Complexity without adding Confusion — Veil of Ruin

A Random Act Of Kindness (aka Why The Blockstars Community 🤘)

Esports Sponsorship Agreements: All What you need to know

Looking forward at 2019: Nintendo

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
S.J. Jason Liu

S.J. Jason Liu

A passionate gamer whose goal is to work in video game development.

More from Medium

Adding laser attacks to our boss

Upgrading A Unity Project To The Universal Render Pipeline (URP)

All about Sky in Unity’s HDRP

Introduction to Shaders