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’
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.
After the script is assigned we will add the rigid body and collider 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.
In the power-up script, we will need to add a case to the switch statement to call the LaserRcharge Method when collected.
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
We will also add the Laser_Recharge to the Power Up Array.
Let see this in action