Phase 1: Ammo Collectable

Now that we have limited the amount lasers the player can have, we should create a collectable to reload the lasers.

Objective: Create a power-up that refills the ammo amount, allowing the player to fire again

First, we will create the collectable and name it Laser_Recharge. Also, adjust the size to match our other power ups’

Creating the Ammo Collectable

Next, we will add the powerup script since this will have the same behaviour as all the other powerups. I will assign it the power-up Id of 3 and assign the power-up audio.

Assigning the powerup Script
adding a comment in the script

After the script is assigned we will add the rigid body and collider components.

Adding the components

Now that we have the collectable created and set up we will move on to the scripts. In the player script, we need a method that will add 15 to the ammo count and update the UI manager. Also, set the can fire to true.

Laser recharge method

In the power-up script, we will need to add a case to the switch statement to call the LaserRcharge Method when collected.

Switch Statement

lastly, we will edit the Spwan Manager script so the Laser Recharge will be spawned along with the other power-ups. We will change the Random. Range to include the ID 3 which is what the Laser Recharge is assigned

Random Power Up ID

We will also add the Laser_Recharge to the Power Up Array.

Power Up Array

Let see this in action

Laser Recharge Demo

Happy Coding!




Unity / C# Game developer

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

Recommended from Medium

Basic XML for Android Devs

Using Dagger-Hilt in Android Project — A step toward clean architecture.

Dependecy Injection


Lesson 5— Creating New Screens

Android Basics — App Bundles

How to easily group projects in Android studio

Disposing RxJava Disposable (Clean Architecture with MVVM Android)

Forget RxJava: Kotlin Coroutines are all you need. Part 1/2

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
Bill Rislov

Bill Rislov

Unity / C# Game developer

More from Medium

BOTY: Gold Mouf by Lute

Ari Swap Corp. 2022 Look Ahead

VBC, a global investment fund, to collaborate with Metarrior as a strategic investor and partner

Connecting MetaMask to Zilionixx Network

The very first wallet