Adding Limited Ammo To Your Game

When making a game, you may want to limit the number of times a player can shoot a gun, use an item, or perform an action. This is just an integer value that is checked before each use and updated after.

The code/logic below can be added to a player script along with your regular shooting code to add an ammo count.

In my next article, we will be going over the creation of an ammo refill powerup!

--

--

--

Hi, my name is Adam Reed and I am a software engineer specializing in Unity and C# development. Feel free to scroll through and check out some of my work!

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

Recommended from Medium

An Overview of the Android Platform Architecture

Code ENOLOCAL Could not install from “android” as it does not contain a package.json file

Practical Jetpack Compose: Get the beta!

Jetpack’s Navigation Component (Complete Guide for Beginners)

Special Forces Group 2

Most Common Android Problems  — Android Pitfalls 🐭 🧀

Somewhat Alarmed — Demystifying Android’s Alarms

Sample code for Flutter Music Player with background audio using Audio Service

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
Adam Reed

Adam Reed

Hi, my name is Adam Reed and I am a software engineer specializing in Unity and C# development. Feel free to scroll through and check out some of my work!

More from Medium

Day 7: The Enemy

git it on the page!

Devlog 28: Added A Charged Shot To My Game

Creating a Simple Vertical Shooter Prototype with the New Input System in Unity 2021