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:
Here were my tasks for yesterday:
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:
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.
Next I needed to figure out the powerup system.
Here is what I came up with:
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.