2D Shooter: Speeding Things Up
Objective: Create the prefab for the Speed Boost powerup and get the code ready for implementation.
Creating this prefab will be a lot like making our first one. We’ll need to drag the sprite we want into the hierarchy to make it a gameobject, then we need to give it the CircleCollider, and Rigidbody2D components.
Now also assign it the powerup script we made when we added the tripleshot; both powerups will be using the same script.
Now for Unity to be able to tell them apart, we need a way to distinguish them within the script. The easiest way would be to assign them numbers. For instance, Triple Shot would be assigned 0, while Speed Boost would be assigned 1, and so on.
Then we can make a switch statement that will read what number the collectible we touch is assigned to, and then run the proper code.
For now you can just have the console log a statement instead of running a method for the Speed Boost to check if the code is working. I’ll be making another article for implementation, so we can see the boost in action.