Introducing the Triple Laser

New Weapon

In this article I’ll introduce a new weapon, the Triple Laser. Although it has a slower fire rate this weapon has the ability to fire three shots at once.


For the time being, I’ve added a few Inspector fields making it easier to make different weapon prefabs using the same behaviour. For debugging purposes I’ve added a bool indicating whether we are firing or not (for code see below).

Object oriented

Creating the Triple Laser Prefab

First I created a new Prefab for the Triple Laser Projectile and tagged it with “Projectile”. This prefab holds three lasers, allowing us to instantiate just one GameObject instead of three.

Triple Laser

Creating the Triple Laser Weapon

To continue I created a new ‘TripleLaserWeapon’ Prefab, added the Weapon.cs to it, and assigned the new Projectile Prefab.

Triple Laser Weapon

The Triple Laser holds three normal Laser Weapons, for the Player it looks like this;

Player Prototype

In the hierarchy I also created a new parent ‘WeaponHolder’ attached to the Fighter jet, and made the weapons a child of this GameObject.

Player Hierarchy

Weapon.cs update

Added a drop down field, a description area, a fire delay scrollbar and a bool for debugging.

Asteroid.cs update

I also fixed a small bug; items where being dropped more than once due to two or more projectiles being inside of the trigger collider at the time of activation. Therefor I made sure the Item is only dropped once.

In the following article we’ll have a look at how we can switch between Weapons.

Previous | Next




Software Engineer — Unity Game and Application Developer

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

Recommended from Medium

Constructing the Bubble Sort Algorithm

Dino Cajic explains how to construct the Bubble Sort Algorithm

Among us analysis

Leveraging GCP to make Facebook custom audience marketing privacy-compliant and scalable (Part 1)

Melania welcomes White House tree after being caught on tape saying ‘who gives a f***’ about…

The Functional Side of Ruby

IaC/DevOps braindump

Introducing a Fuel System

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
Gert Coppens

Gert Coppens

Software Engineer — Unity Game and Application Developer

More from Medium

Pump The Brakes…

Adding a new ability to our prototype — The Triple Shot

Unity : AI [Navmesh implementation (Part II)]

Creating a Pressure Pad in Unity