Control Your Fire!

Andrew Lengen
3 min readMar 25, 2021

Well, we’ve created our laser prefab and now we need a laser script. How else are we gonna get it to move? So let’s create another C# Script within our Scripts folder and drag it over to our Laser prefab:

Boom, easy!

Now that the script is inside our Laser Prefab, let’s figure out how to get it moving! So to start off let’s create a variable for the movement speed of the laser.

[SerializeField] so that we can ma-nipple-ate it on the Inspector!

Now that we’ve got that set up, we get the laser to shoot from the cube by using Vector3.up, which is shorthand for
new Vector3(0, 1, 0)

Alright, our laser has a speed and will move up whenever

Now let’s move on to getting this baby to pew!
Let’s head into our Player Script: create our variables, assign our Laser Prefab, create our method and set it up in our void Update()

Cool-down crossed my mind… we’ll see….
Method called so that we can get it movin’ once our code is in
Method created to write all of our code

So, our variables have been created, our method is created and assigned, and before I forgot I assigned our laser prefab.

Lasers set… to kill!

Let’s now start making our pseudo-code:

“If we hit our fire key, which we’ll be assigned to Spacebar, we will fire our laser.”


Time.time — time that has passed each frame
Instatiate — to provide an instance of or concrete evidence in support of (a theory, concept, claim, or the like)

The offset of 0.75f is to make it look proper, and not have the laser spawn from inside the cube

Now, we hit save and…




Andrew Lengen

If ambition and practicality amalgamated, it would be me! I am here to climb the mountains of my ambition and catalog my journey so that someone can be changed!