New Feature — Burst Shot Collectible
Objective: Providing the player with a secondary way to shot down the enemies with a Burst Power-up
Create the Burst Power-up Prefab
Make a copy (duplicate) of the Ammo power up by selecting it and pressing CTRL + D and rename the new prefab to BurstPowerUp.
Let’s add the Burst to the Power type enum so we can select it as the Power Up type for the new prefab
The Burst Shoot prefab itself is simply a number of lasers set in their initial position and when the prefab is instantiated, the laser then starts its normal movement behaviour which is to move forward.
Next, we will code in the behaviour for when the player ship touches the power-up. It will activate the secondary fire for 5 seconds.
First, we call the method from the PowerUp script to activated the Burst fire.
The BurstShootActive sets the flag to true to enable the burst shot and starts the coroutine that sets the flag to false after 5 seconds.
The PlayerShoot script has a reference to the prefab.
During when the Burst is active, the Fire method fires off the burst prefab each time the fire button is pressed.
I finally drag the prefab to the Player Shoot script, add the Burst Power-up to the Spawn Manager and play the game.
If you enjoyed reading this article give me a Clap, also if you would like to see more, “Follow” me, so you may be notified of future releases. You may also send me a message if you need any further help.