Step 7 — Triple Shot Powerup

Nicholas Lim
2 min readApr 15, 2021

Now that we have the basic structure of a game, it’s time to spice things up a little with some collectible powerups. First up is a powerup that allows us to fire three lasers instead of just one. Three. Lasers.

First of all I created a triple laser prefab by attaching three Laser prefabs to an empty object called Triple Shot, arranging them around my Player sprite so that they align with the guns, then I make the Triple Shot a prefab.

Make sure Triple Shot object and lasers are Z-coordinate zero before combining them to avoid Instantiate position weirdness

I do a setup for the powerup object too by giving the sprite a Rigidbody2D (disable Gravity) and Collider2D (IsTrigger on)

Circle Collider in this case.

On the Triple Shot powerup I give it a script called Powerup with the following

Powerup script

This powerup disappears once it’s fallen past y-coordinate -5.2f, and if it hits a Player, it calls the TripleShotActivate() method on the Player, before self destructing.

Player script

The TripleShotPowerActivate() turns the _isTripleShotActive bool true, which in turn will make the firing logic shoot the Triple Shot prefab instead of the usual one laser.

Finally I add code in the SpawnManager to spawn this Triple Shot powerup at an interval of time, similar to how it spawns enemies.

--

--