60 days to become a game developer. Day 44.

Hello! Here is a recap of yesterday, Day 44 of my 60 day challenge to become a Unity Game Developer!

Yesterday, I got into my favorite part of all of this which is tackling these open ended challenges and coming up with my own interesting solutions!

Here is where I’m at:

Image for post
Image for post
Every time a player receives a power up their weapons become increasingly powerful. If the player takes damage, they will revert back to their little fireballs lol, if they get hit twice without collecting a powerup they die. I was in charge of the behavior which instantiates the weapons rather than the weapons themselves so the higher level weapon’s behavior will look A LOT better than this.

Here were my tasks for yesterday:

Image for post
Image for post
Image for post
Image for post

The weapons stuff I am tackling with a teammate as it was a bit bigger of a task than some of the other features. He is working on the weapon’s animation/behavior and I am working on the systems. Very happy about this because I prefer to work on the “behind the scenes” stuff. The health portion I am doing on my own.

Here is how I started to tackle this:

So my main goal for yesterday was to figure out how we wanted to implement the weapons power up system and get the health situated.

The health was pretty easy, here’s how I approached that.

First thing I did was jot down some pseudocode:

Image for post
Image for post
Using pseudocode helps me to keep organized and have a clearer picture of what needs to be done in smaller steps. Here is an example of my player health pseudocode.

Based on the course certification requirements for the health, all that really needed to be done at this point was to create a float that could be used as a health variable and a method that would deduct from this every time the player took some damage. This method also takes care of destroying the player if their health drops to 0 or below.

Image for post
Image for post
I decided to set the float to 1 so that if we wanted to create some sort of corresponding health bar as a UI element all we would need to do is make reference to this variable and set the image type to horizontal fill.
Image for post
Image for post
Also created a tester method to make sure that everything was working as intended. Later we will coordinate a way to call the damage method either from the enemy, enemy’s weapon, or by some other means.

Next I needed to figure out the powerup system.

Here is what I came up with:

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

First thing I knew that I wanted to do was create a variable to reference how many powerups the player has received(_weaponPowerUpId) . I also wanted to create some sort of switch case that would run anytime a powerup was collected. The purpose of this was to make reference to each powerup number’s corresponding weapon behavior, increment up to the next weapon when needed, and set the health back to maximum health. From there I created an int enum to hold the weapon references, created a firing method, and a game object array to hold each respective prefab.

Challenges:

  • Took some time to land on the enum for referencing the weapons as I actually have never used an enum before. At first I was going to use a bool array but quickly realized it would be a pain to have to switch everything from true to false back to true, etc. After some research enum seemed like an obvious implementation and I’m pumped to have learned something new.

Today I am working on cleaning everything up and maybe starting on a new feature!

Talk to you soon.

Written by

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