Implementing Speed Boost Powerup in Unity
Make the player faster when collect a powerup
Objective: Create an script to make the player move faster when collect the speed boost powerup
In this challenge I’m gonna show you how to modify the player speed when collecting the powerup. So the first step is to declare some variables to have control of the speed in each moment of the game.
Then we have to create a coroutine to modify the value of the speed, wait 5 seconds and set the speed as default again and create a public function to start the coroutine.
After that in the powerup script in the OnTriggerEnter we have to check if the powerupID is equal to the speed boost id (1 == Speed Boost) and call the function to activate the powerup.
Now we can run the game and see how the player moves faster when picking up the powerup.