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:
- Create a functional prefab(including collider, rigidbody, audio source, animation, and script).
- 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!
Next: Repair Your Ship