Powerup Series: Creating Alternate Functionality

Part One: Creating a Triple Shot behavior

Erin Kerr
3 min readOct 19, 2022

Now that Brave the Expanse has some nice-looking assets, let’s add to the base game with powerups! This multi-part series will go over how to add a powerup to your game, step by step.

When you boil it down, a powerup is just an object you collect in-game that temporarily alters or enhances the gameplay. As an example, let’s walk through creating a Triple Shot powerup, where the Player shoots three lasers instead of one.

Creating the Triple Shot object

Adding three lasers to Triple Shot parent object

Using the existing lasers, we can build a Triple Shot object by adding three laser prefabs to an empty game object.

Aligning the Triple Shot lasers over the Player

Then, center both the Player object and the Triple Shot object at (0,0,0) and align the lasers where desired on the Player object. For a better-looking TripleShot, make sure the left and right lasers mirror each other on the X axis and share the same Y value. With the lasers aligned within the TripleShot parent object, they will maintain their relative positions. Drag and drop the TripleShot parent object to the Prefabs folder to save the object.

Building the Triple Shot behavior

Since the individual laser movement is already built into the Laser objects within the Triple Shot, the only other change needed is to allow the Player to fire the Triple Shot. To do this:

  • The Player needs a reference to the Triple Shot prefab
  • The Player needs a indicator for when the Triple Shot should be fired vs. the standard Laser
  • The Player needs to instantiate the Triple Shot instead of the standard laser when indicated
Variable to hold reference to Triple Shot prefab

To give the Player a reference to the Triple Shot prefab, add a variable in the Player class to hold the reference and add the SerializeField attribute. Then, assign the Triple Shot prefab via the Inspector.

Boolean variable to indicate which projectile to use

To add an indicator for when to fire the Triple Shot or the standard laser, create a boolean variable. When true, the Player should fire the Triple Shot. When false, the Player should fire the Laser.

If/Else statement to determine which projectile to instantiate

Lastly, update the existing FireLaser method to check the Triple Shot Active indicator. If true, instantiate the Triple Shot prefab; otherwise, instantiate the Laser prefab.

Triple Shot behavior in action

Now, if the we check the Triple Shot Active indicator in the Inspector, the player will fire the Triple Shot.

Next up in the Powerup Series, we’ll create and animate a Powerup object!

--

--