Ammo Collected!- Game Dev Series 36

S.J. Jason Liu
2 min readMay 31, 2021

--

Objective: Create a collectable ammo powerup to refill.

Since we have limited the ammo, it should be better if we add an ammo powerup.

Here are what we should do to create an ammo powerup:

  1. Create a functional prefab(including collider, rigidbody, audio source, animation, and script).
  2. Add extra lines to code to make this powerup works.

Create a functional prefab

Drag the first sprite that you prepared for this powerup into hierarchy as a gameobject. Rename it and add every component you need.

And also set the animation!

Don’t forget to drag the ammo powerup back to Project window as a prefab.

Add lines of code to scripts

First, in the Player script, create a public method to update the ammo and also update the UI.

Don’t forget to send the ammo counts to UIManager.

Add another switch case in Powerups script to access the method we just created in Player.

Then we can assign the ID number to ammo prefab.

And make the ammo prefab in SpawnManager routine.

All done! We can test it now!

--

--

S.J. Jason Liu

A passionate gamer whose goal is to work in video game development.