PowerUp +Ammo

phi golden
Nov 7, 2022

--

Objective:
1. Create a power-up that refills the Ammo Count.
2. Add a Sound Effect to Refill Ammo
3. Add a 3D model to collect
4. Reloading Sound Effect

Featured Image:

Deciding on an Ammo Collectible:

I am decided on this type of ammo icon (3D).

Sound: Just looked for some Sifi reload sounds

PowerUpBehavior.cs

Code:

Added more conditions. Yes, this breaks the Open and close principle.

Player.cs:

PowerUpBehavior calls this Method from Player.cs

1. The heart of the logic for limited ammo is here UserLaserPool() we first check if the game has started if so start limiting. _ammoBank — and UpdateAmmo is under the _ammoBank is 0 check because once we hit zero it will skip everything under this block of code with a return.

From a future article but when ammo is refilled/reset, a check for an ammo update/count to fire or will skip the rest of the code in UseLaserPool() by a return when _ammoBank is ≤ 0

SpawnManager:

Drag and drop Ammo collectibles

AmmoAnimation.cs:

This simple rotation when Active, animation Should always be in FixedUpdate.

Game Play Video:

Thanks for Reading…
.
.
.

--

--