Day 19: Speed Powerup Behavior
Jan 23, 2023
The speed powerup is going to change the behavior of the player by giving it more speed. So, we have to work in the player script. Let’s add a boolean to check if the speed powerup is picked up and a speed multiplier.
Like we did for the triple shot powerup, we need a function to change the player’s speed. The function MoreSpeedActive() is going to:
- Change moreSpeed to true
- Multiplies the speed by the speed multiplier
- Start the power-down coroutine
The power-down coroutine will:
- Let the power up run for 5 seconds
- Set moreSpeed back to false
- Divide speed by the multiplier so that speed is back to normal
Now in the powerup script, have the speed powerup case call the MoreSpeedActive() function.
Now our game has two working power ups.