From Photographer to Video Game Creator — Day 2

Day one was definitely a lot, but after a good nights sleep, I felt ready to take on my second day of coding! Before diving back into the lessons, I decided to give myself a little extra challenge: start a new project in Unity and attempt to get back to the same spot with a moving cube.

This proved to be more challenging than I thought. Right off the bat just remembering how to set up the Hierarchy and Project folder took more memory than I expected. I took my time and followed my notes, and slowly but surely my project took form and I was able to create a moving player!

Now that my quick refresher was completed, it was on to the lessons. Step one was to finish completing my player movement by establishing boundaries. The goal was to limit the movement on the y axis while allowing the movement on the x axis to wrap to the opposite side of the screen. Here is a little peek at my code:

Next up… LASERS!

Just the idea of shooting lasers makes me excited. However, the process had quite the learning curve. I began by making a little capsule and assigning it under the Scripts folder as “Laser”. The object known as “Laser” will be a Prefab.

PAUSE

What’s a prefab?! A prefab is a game object that can be instantiated at run time and can hold a reference to other objects as well as each other. Instantiate is simply the process of creating an object within Unity. Setting up an object as a prefab can be extremely useful anytime there will be multiple of the same object being used. This allows them to be grouped and edited as if they are all one object. Major time saver.

Let’s continue. The instructor came out swinging today, hitting us with multiple challenges that required some critical thinking and some expert Google’ing. A few of these tasks included getting my laser to shoot in the vertical direction, offsetting the initial spawn point of the laser, and coding the laser to destroy once it has left the screen. All I have to say… is mission success!

I ended the day with one last lesson on fire rate. This required the understanding of “time.time”. This is the concept of passing time and how long the game has been running. I set the fire rate to 0.15 seconds and made sure to include it with my Serialized Fields so that the option was available to change the inputs without going back to the code. Here is look at the ones I have created so far under my player script.

That’s all for today, tomorrow I am starting with developing enemies. I don’t think they will have a chance against my little green lasers!

Peace!

-Myles M.

Professional photographer on a journey to create my first video game!