From Photographer to Video Game Creator — Day 4

Whatsup! I’m almost through my first week of coding and my brain is definitely feeling fatigued. I decided to spend the first part of my day reviewing terminology and the notations for various codes which did make me start to feel a little better as things were starting to make more sense.

After my quick refresher it was time to hop back into some lessons. First up, how to take my 3D objects and turn them into 2D graphics. It sounded intense, but this process actually isn’t too lengthy at all! Step one was to add a background and adjust it to fit the game view.

I even played a few test games because it was already looking way cooler!

Now it was time to change out my beloved cubes. Bye bye little buddies but hello super awesome spaceships!

There are many ways to complete this process, but the main thing to remember is to attach the code to the new 2D objects and make sure to assign the appropriate tags so that the code will know which object to reference. It is also important to change out the 3D components of each object with 2D ones. This includes a 2D Box Collider and a 2D Rigid Body. The last adjustment is made within the Enemies script changing the Trigger Collisions to 2D. This allows the objects to still recognize when they are colliding.

I then started my lesson on power ups, specifically a triple shot power up. I quickly learned the importance of spelling and how just one letter, number, or symbol can completely break your code. Here was my first attempt at shooting three lasers at once.

Yep, those little red dots are my lasers. Not only were they small, but the lasers were also offset from my spaceship. Let’s move on to take two…

Alright, I now have the right sized lasers but they are still offset and this time in the opposite direction. After some thorough investigation… I discovered my error, and it wasn’t even in my code! It was in my laser prefab! My lasers starting position wasn’t correctly lined up with my spaceship causing the offset to occur AND I had a value of 1 for the scale on my “z” axis. This was the cause for my tiny lasers. Cleaning up my laser prefab starting position and setting my “z” value to 0 for scale fixed my triple shot and my game was now running smoothly!

Today was full of errors and troubleshooting, BUT figuring out these roadblocks is definitely a rewarding feeling!

See ya tomorrow!

-Myles M.

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