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

Display Cryptocurrency Prices Using Paging 3 Library and Jetpack Compose

An In-Depth Look at gRPC for Android

https://developers.google.com/web/fundamentals/performance/http2#streams_messages_and_frames

Android — Bitbucket — Pipeline — CI/CD with Firebase App Distribution

Boss battle phase 2: Spawning additional enemies during the boss battle.

Firebase Crashlytics in Android

Apollo GraphQL for Android

Say goodbye to Flakiness : Testing Coroutines and Kotlin Flows [Part 1]

Kotlin Coroutine

Custom Dialog with Animation using Jetpack Compose

jetpack compose custom dialog

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

Mastering Unity Scripting | Summary — Chapter 2: Debugging

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

MVC Pattern in Unity — Less Code Dependency and Better Code Architecture

Attack while jumping