Day 18: Creating the Triple Shot Powerup

Alex Frankovic
3 min readAug 31, 2022

--

Objective: How do we begin to construct our first powerup for our player in our Unity Project?

So, now that I have moved deeper into my project, it’s time to create some more objects and behaviors to get more action going on. To begin, I will start to move into powerups and what it can do for our player for a specific time. Let us begin with our triple shot powerup!

First thing is first, I will be creating a new object and giving it the name Triple Shot. Since the lasers will share similar behaviors, I am going to duplicate three of them and drop them into my new created triple shot object.

creating new gameobject and naming it triple shot

Once this is done, I look into my scene view and adjust it on all axis’ to make sure the offset at which the lasers are fired at have a smooth and clean feeling to it. This will imply that these lasers will fire from these locations when we adjust our C# script.

adjust the three lasers on all axis’

Afterwards, I can jump into my player script and begin to add new variables. The two new variables will be

  • One in which will indicate when the powerup is activated (Bool true/false)
  • One in which will indicate the new “gameobject” (“tripleShotPrefab”)
creating the two new variables

Next, I wanted to write down pseudo code (//) to sketch out the idea of what I am trying to imply. Simply converting what I had in my own words into logic, we should get something like this shown below:

Using logic to indicate when triple shot will be used

This basically states that when triple shot is set to true, we will be able to use our triple shot power up where as if it was false, we would be set to firing our regular single shot laser. Just a basic bool statement that we are trying to indicate whether its true or false and what will happen on both sides of that coin.

If we jump into the project and apply the prefab and toggle between the checkbox you will see that I fire three lasers when the box is checked in (true) and firing single shots when the box is clear (false).

toggling between true and false on triple shot function

Next thing I will be covering will be creating an object that when our player passes through, we will gain that powerup ability for a certain amount of time. Stay tuned!

--

--