Powerups: Making them modular
Since I plan on having more than just 1 power-up, I will make it something a bit more modular.
Making it modular, means I don’t have to create a new script for each and every variant I need. Instead, I can use one script that holds enough information for it to indicate what powerup it is.
Doing it this way, I only have to change a variable and replace the sprite!
I opt to use IDs to represent the different kinds of powerups.
Now I simply need to pass the ID of the powerup to the Player when it’s collected. The player script then handles how that powerup should affect it.
public class Player : MonoBehaviour
private void ActivatePowerup(int powerupID)
if (powerupID == 0)
if (powerupID == 1)
// increase speed routine
Now we have an easier way to handle powerups, that is extendible.