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.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response