Secondary Fire Powerup

Today, we will make a secondary powerup, that will look like this:

We need to create the powerup GameObject as well as the laser.

To make a laser, I used the sprite that is used for regular shots but I extended it on y axis and make it a little thicker.

We need to add Box Collider 2D, Rigidbody 2D with gravity set to 0 and the Laser script. Add a new tag and assign it to our new weapon.

In the Laser script, we need to set the speed to 0, so it will stay in place.

Because we won’t have to spawn multiply lasers we will move the “SuperLaset” GameObject as a child of the Player. When we collect the powerup for the secondary weapon, we will just active the GameObject. After 5 seconds we will deactivate it.

In the Player script, we will create a new variable of type GameObject called _superLaser.

Create a new method and a new coroutine. In the SuperLaserActive() method we need to active the GameObject and start the coroutine.

In the coroutine, after 5 seconds, we will deactivate our secondary weapon.

In the Powerup script add a new case to the switch statement:

Now, we will make the powerup GameObject for our laser. Im using a sprite of a laser gun for our powerup.

Change the name, add the Circle Collider2D and Rigidbody2D, and set gravity to 0. Add Powerup script and assign the sound effect. Change PowerupId to 5. Add the Animation for color shifting.

Make a prefab and add it to the Spawn Manager script.

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Accessing Deepnote machines on the web

IoT — Raspberry Pi Container and System Monitoring with InfluxDB, Telegraf and Grafana

Long Polling, a Real-Time Alternative

WOULD YOU LIKE TO TRY OUT SOME UNRELEASED UPDATES ON OUR WEBSITE?

Git in here! Intro to Github. Part 1

Micronaut | 3 ways to upload files via HTTP

Rabbit hole (episode 1) — Tuning HTTP Connection Pool for S3

Tutorial: Automating Customer Service Easily Using Freshdesk and Slack in 10 mins!

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
Kinga Osińska

Kinga Osińska

More from Medium

Project 1: Museum Rebrand

To Pimp a Butterfly- Kendrick Lamar

Bands in NYC Kept Creating and Collaborating in Pandemic Times, and Now They Are Thriving

Definity Legend