Implementing Speed Boost
2 min readMar 29, 2021
For today’s article, I’ll be going over how I added in the Speed Boost Power-up.
Setup
I first create a Speed_Powerup
game object and turn it into a prefab with the following components attached:
- Sprite Renderer: I set the sorting layer to Foreground to prevent the power up from showing up behind the background image in game
- Circle Collider 2D: I set the collider to trigger to true so that the player ship can pick up the power up on object overlap
- Power Up: Contains
OnTriggerEnter2D
logic to determine how the player should react when picking up this power up. ThePower Up ID
field is used to describe what kind of power up that player has the chance to pick up.
Logic
When the player picks up the speed power up:
- The player will receive a speed boost based on the
speedMultiplier
variable. - The player will experience speed boost for a fixed amount of time. In this case, 5 seconds.
- After the speed boost duration finishes, the player will go back to their normal move speeds.
In this next article, I’ll be explaining more about how I developed a modular power-up system. Stay tuned!
Thanks for reading!