2D Shooter: Implementing the Speed Boost Powerup

Sabrina Windsor
2 min readJul 11, 2021

--

Objective: Increase the speed of the player when colliding with the collectible, and end the boost after five seconds.

In the previous post we got some code prepared in the powerup script where we will be calling the method we’ll be making right now. In the player script, we want to create a new public method (so the powerup script can access it) that will hold the code that enacts the proper effect we want. We also want to make another IEnumerator method specifically for the Speed Boost so we can add a cooldown.

Name them SpeedBoostActive and SpeedBoostPowerDownRoutine respectively.

Now make a global bool variable _isSpeedBoostActive. On its own, it should be false. This bool is important for the cooldown.

Now the whole code should look like this:

My numbers are a bit exaggerated for the purpose of making my gif. Realistically, the number added to the speed wouldn’t be so much, but you can play around with it and see what you like. Just make sure to subtract or reassign the speed to the proper value in the cool down.

Now all that’s left is to call player.SpeedBoostActive(); in the powerup script.

Case 2 will be for the shield powerup we’ll make later.

--

--

Sabrina Windsor
Sabrina Windsor

Written by Sabrina Windsor

Currently learning to code with the help of GamedevHQ in order to someday my my game ideas come to life!

No responses yet