This is a pretty simple fix in itself!
If you have noticed the Hierarchy gets bloated with the Triple Shot because it is not being destroyed as soon as it goes off screen like the laser, why? Parents.
If you remember earlier we created a container for the Triple_Shot, which is the Parent. It won’t go without a fight! Here is our weapon of choice!
I realized I forgot to add in the means to have it deactivate after a certain amount of time — we need IEnumerators!
With our IEnumerator, we’re going to allow triple shot to be enabled for 5 seconds, then disable triple shot!
We now need to make a call to it from our function, _tripleshotCheck()!
It’s time to create our power-up! We’ve simulated triple shot through our Inspector through a toggle and now we need to make the actual pick-up!
Drag a sprite of our choosing to the Hierarchy, renaming that sprite to “Triple_Shot_Powerup”, resizing the sprite, giving it a 2D collider and checking the “Is Trigger” box (because this will be an “OnTriggerEnter2D()” event!), and lastly adding a “Rigidbody 2D” with “Gravity Scale” set to zero!
Let’s also get our “Powerup” script made in our Scripts folder then drag that into our Triple_Shot_Powerup!
With all that we can start writing our script for our Power-up!
Since our prefab is set-up, we can start working on the power-up. We’re essentially collecting a sprite that tells the Player, “Yo, you can use this” and enable the Player to “Triple_Shot”.
Planning this out we need to check if Triple Shot is enabled, then fire the Triple Shot —…
We must rebuild this laser — it’s just easier that way. Let’s start by deleting the 3D “Laser” out of our “Prefabs ”folder then drag-and-drop our “Laser ”sprite from out of our “Sprites ”folder in the Project hierarchy onto our “Hierarchy”. Once it is in our Scene, resize it to…
Let’s get to converting our villain to 2D by selecting him in our Project > Prefabs folder, then in the Inspector we want to select Open Prefab
From here, you should see this in your Inspector!
Let us remove the Mesh Filter, Mesh Renderer, Rigidbody and Box Collider. Why? We…