Making Modular Powerups

Rook Sullivan
1 min readApr 28, 2021

--

In an earlier article, I mentioned the three powerups I was going to be adding to my game; Triple Shot, Speed Boost, and Shield. Now that I have my Triple Shot implemented in my game, its time to begin work on the other two. First, however, I need to modify my existing systems to handle multiple powerups.

Rather than creating a unique script for each powerup, I can simply add a new variable that allows me to assign each powerup object a unique identifier in the inspector and apply logic based on that identifier. For instance, while powerupID is set to 0, it will apply the Triple Shot logic to the player when collected. In the future, a powerupID of 1 will apply the Speed powerup, and a powerupID of 2 will apply a Shield. This is done through a series of if/else if statements that are triggered when the powerup is collected.

Once the logic is implemented for the other two powerups, I simply need to assign them their respective powerupIDs in the inspector and enable the currently commented out code.

--

--

Rook Sullivan
Rook Sullivan

Written by Rook Sullivan

Non-binary game dev sharing my experiences in Unity.

No responses yet