Ammo No Enough!- Game Dev Series 35

Objective: Create limited ammos & ammo counts UI.

To increase the difficulty of a shooter game, there is one option is limiting the ammo.

To limit the ammo, we will need to make some changes at shooting method and UI.

First, create an integer variable as ammo and set the default counts to 15. Under the shooting check statement, decrease it by one per each shot.

Then insides the ShootLaser() method, make it can only fire if there is still have ammo.

Next is the UI part.
Create a new ammo text gameobject in Canvas.

I used the laser sprite to make it visualize instead of word only.

Then create the variable and also a public method to update it.

To prevent some calculating error, make it only shows 0 in else statement.

Don’t forget to drag the ammo text gameobject into UIManager in Canvas.

Then we can call this method when we shoot. Back to Player script and add another line.

That’s it! You should get a limited ammo now!




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

How to Install PySpark

How to Install PySpark

Open Source and the Linux Kernel

The Linux Kernel has infinity contributors on GitHub

Elevate your software developer career from good to pro- best software engineering practices and…

No, DevOps ≠ CI/CD

Developing a website in accordance with the new project concept.

30 MOST READ Tech Stories of Q1, 2019

Laravel-Injection And Inversion Of Dependencies

Monitoring a UPS With nut and lighttpd on Linux — Part 1

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

Creating An Advanced 2D Player Controller Without Any Unity Components! (Part 1)

Day 103: Creating A Ledge Grab in Unity Part 1

Learning Unity — How To Make A Loading Screen

Creating a Keystore File within Unity