From Photographer to Video Game Creator — Day 11

Myles Marion
3 min readDec 15, 2020

Coding is a weird thing…

I feel like the more I learn, the more confusing it becomes. I make a connection and for a quick minute everything seems to make sense, and then it doesn’t. It’s frustrating but at the same time extremely addicting.

That being said, today was a lot of fun! I polished out some bugs with my Enemies and even gave them the ability to fire lasers. This opened up a whole new aspect of the code and drastically increased the script communication.

Let’s start simple.

The first task was to make the enemies fire lasers at random intervals. I created an enemy laser prefab and assigned it the same laser code as my Player lasers. Now, all I had to do was differentiate the Player lasers and the Enemy lasers. I did this by creating a “MoveUp” and “MoveDown” void referencing the movement direction of the lasers.

Giving the Enemies the ability to fire lasers was a little more challenging. The code begins the same as the lasers for the Player, except this one needs to fire randomly on its own. The “_fireRate” is set to a random time between 3 and 7 seconds and the “_laserPrefab” is instantiated from the position of the Enemy object.

All that was left was to tell the Enemy Lasers when they were colliding with the Player and that they should do damage to the Player. I noticed a small bug at this point where my Enemies could destroy each other, which was fine, but they were also adding to the Player score. I am adding this to the list of bug fixes for tomorrow and hopefully I can figure out a solution!

Here’s a fun, short code for ya! This one allows the game to be closed out from full screen with the escape key. There is literally a command for everything!

Pretty stoked on the progress today and even more stoked that I’m getting a better grasp on the script communication. Learning how to Google these issues and using the correct key words is also proving to be super important.

Here’s a quick little progress video on my game at the current moment! See ya tomorrow!

-Myles M.

--

--

Myles Marion

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