Creating Triple Shot Power-up

Harvey Limbo
2 min readMar 29, 2021

For today’s article, I’ll be going over how I implemented the triple shot!

Setting up the Triple shot Prefab

I took the existing Laser prefab and created a new game object named Triple_Shot that holds the 3 laser prefabs. Next, I moved each laser in the container next to where they would spawn from. Afterwards, I made the Triple_Shot game object into a prefab by storing it in the Prefabs folder.

Setting up the Triple shot Power-up Prefab

To enable the triple shot power-up for the player to use, I created a triple shot power-up prefab that contained the following components:

  • Sprite Renderer: used to render the power up graphic
  • Circle Collider 2D: enabled Is Trigger to true to ensure Player can pick up the power up on collision
  • Rigidbody 2D: Turned off gravity and used the Power Up script to control how many meters per second it would fall downwards
  • Animator: to show the flashing text to grab the player’s attention to pick up this power up
  • Power up: a custom script that contains the logic of how fast the power up falls and the behavior of when a Player picks up or overlaps with this game object

The Code

When the player picks up the Triple shot power-up, the player has it enabled for only 5 seconds. This logic is accomplished by using co-routines inside of the Player script:

To activate triple shot, the Power up script implements the onTriggerEnter2D function to determine which game object overlapped with itself. If it is the Player game object, then activate the power up:

Seeing Everything in Action

After constructing all of the game objects and doing some scripting, I have my first working power up complete :)

Thanks for reading!

--

--