Next, we will create a speed boost powerup.
We can create a coroutine function to our Player script as what we done to triple shot. In this coroutine, we will increase the speed within the limit time.
Then we need a speed boost prefab to collide with Player.
A speed boost powerup is quite similar to triple shot powerup.
Same as drag in the basic sprite,
add a collider and a rigidbody.
And don’t forget the Powerup script.
However, since we only create one script for all the powerups, we need to make our script can identify which powerup that player just collided with.
To do that, we can simply make an easy-to-use modular for powerup.
Open the Powerup script, then create an integer variable called _powerID, and also make it a SerializeField.
As it shown in the comments, we will set the ID numbers to each powerup.
Then we can if statement to verify which powerup that we collided with.
Back to Unity, we can change the ID in the Inspector. Change the ID number to each powerups.
Let’s check if our player can really identify the powerups.