Hello. Today is day 10 of my 74 day challenge to become a Unity Game Developer!
Today may have been one of my favorite days so far! As I mentioned in my last post, I finished the game for the most part as all the tutorials are done. Now as part of the course I get to go through a series of challenges that test my knowledge and allow me to apply what I’ve learned.
Here’s what my game looks like today:
Here is a walk through of the first challenge I solved:
- First challenge: “Limit the lasers fired by the player to only15 shots. When the player is out of ammo, provide feedback through on-screen elements or sound effects. (ie: beep or ammo count displayed on screen)”. I decided that for this challenge I wanted to add a text component to the UI and have it flicker when the player’s ammo hits 0. When the ammo is equal to 0, I wanted to disable the laser as well. To achieve this, the first thing I did was create a text component in the UI. I hardcoded in the string so I could figure out the layout (actually if you look closely at the GIF above you can see how I still need to take it out) . After that I opened the UIManager script to create a variable for the text. In the UIManager I also needed to create a method that passed in a parameter of type int so that once I created an int to keep track of the player ammo in the Player script, I would have a way to convert it to a string for the UI display. This method also takes care of the the flicker feature which was created using a Coroutine.
- In the Player script I created an int to hold the player’s ammo and added into the LaserBehavior() a decrement by one to the ammo every time the laser is shot, an if statement to set ammo back to 0 if it falls below 0, the UpdateAmmo() from the UIManager script to pass in the ammo int, and an if statement to only fire the laser if the ammo is not equal to 0.
Here are a few other things that I worked on today:
- Pumpkins! Not sure what I’m going to do with these pumpkins yet but in honor of my favorite holiday coming up this Saturday I want to try to work it in somehow…. we shall see.
- Added a new enemy that I’m still working on. That’s the cool guy in green. Will provide an update on that tomorrow. Got some weird behavior going on with the animation that I’m trying to figure out.
- Added Thruster feature. Challenge: “Move the player at an increased rate when the ‘Left Shift’ key is pressed down. Reset back to normal speed when the ‘LeftShift’ key is release”.
Challenge I faced:
- Never recovered my files from yesterday due to Git issue mentioned in my post from Day 9! Good learning lesson though.
Today was a great day overall. Being able to get creative and come up with my own solutions is so satisfying. Its what I enjoy the most about programming. Excited to get back at it tomorrow.
See you then.