Ammo Collected!- Game Dev Series 36

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.

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.

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!

--

--

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

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
S.J. Jason Liu

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