Space Shooter Features: Ammo Count

Ammo Count Feature:

  • Limit the lasers fired by the player to only15 shots.
  • When the player is out of ammo, provide feedback through on-screen elements or sound effects. (ie:beep or ammo count displayed on screen)

Solution Steps:

  1. Add a Text UI element to the scene and place it somewhere so that it does not affect the game area.

2. Add an “ammoText” variable to the UImanager script and assign the previously created Text UI element to it using the “[SerializeField]” option. Create an “UpdateAmmo” method to display the current amount of remaining ammo.

3. In the last step, update the player’s Laser method.

First create an “ammoCount” variable, then decrease its value after each laser initialization and update the ammo count display. Test the game. The code only counts single shots. A triple shot as a powerup is not counted against the ammo count.

--

--

--

Hi, I’m Damian, a Unity Software Engineer who loves building education and simulation games.

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

Recommended from Medium

Distributed ACD Transactions Simplified With Orchestration Pattern

web API with Azure AD authentication in .Net Core

How to Learn Programming for Data Journalism (The Guide from the Ordinary Journalist)

Kotlin Coroutines

The Twenty-first Century Mobile App Framework (Flutter)

Upsert and Upsert all with Spring Data JPA and Cockroach DB

How to brick all Samsung phones

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
Damian Dąbrowski

Damian Dąbrowski

Hi, I’m Damian, a Unity Software Engineer who loves building education and simulation games.

More from Medium

How to Win the Race Using Director

What is Filebase and How do you use it?

Animating Sprites In Unity

Unity Tutorial — Toon Shade in HLSL