Power Up System in Unity — Part 1

Creating Triple Shot Prefab

First, let’s create a prefab that we will be using. It’s simple as creating an empty game object (make sure to reset its position to 0,0,0), then add 3 laser prefab under it. You can place these 3 lasers as shown below.

Triple Shot Prefab Behavior

So, what do we need to do in order to be able to switch between single and triple laser shots? We can implement a bool variable that will check ‘is Triple Shot Active or not?’.

  1. Create a variable of bool ‘isTripleShotActive’ as ‘false’ to start with.

Create TripleShot Power-Up that can be collected

Now that we have a tripleshot laser prefab created, it’s time to create another prefab that we can collect and enable tripleshot ability.

  • In Circle Collider2D — check ‘Is Trigger’ under Collider! (We will need this to use OnTriggerEnter() Method)
  • In Rigidbody2D — Gravity Scale to 0, so that we don’t get affected by gravity.

PowerUp Script

Once you’ve done that, let’s create a new C# script called, ‘PowerUp’.

  • move it down at speed of 3, then destroy it when it is at the bottom of the screen.
  • When it collided with the player (by looking for a tag “Player”), we will enable the bool variable ‘isTripleShotActive’ (that we created above) to true. Then, destroy it.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Du Young Yoon

Du Young Yoon

XR Unity Developer / Designer / Architect