From Photographer to Video Game Creator — Day 15

Today was sick. My goal was to finish off my ammo counter and create a cool animation to display the current ammo for the player. I never really thought too much about Heads Up Displays (HUDs) and what goes into them until today. I kind of took them for granted because they were always just there.

To start with, I wanted to create a glowing haze around my ammo counter that would blink read when the ammo is low. I did this by making an array for ammo glow that could be assigned separate animations in the inspector.

The next step was to set up the code to cycle through the ammo and turn on the correct glowing animation. This process was pretty similar to how I created my shield animation. Here is the code for my ammo counter which I wrote on my Player script.

I also needed to tell my Player what to do when the ammo powerup was collected. The following code tells the Player to reset the ammo to 5, play a reload audio clip, and reset the low ammo animation back to the normal blue glow animation.

Things were going pretty smoothly up to this point, which was awesome, so I decided to dive a little deeper and push myself a bit further. I wanted the ammo counter to follow the Player so that it was easier to find and read. I did this by attaching another canvas to the Player object. The key here was to assign the render mode to World Space which would let the ammo counter to float beside the Player object and mimic the movement.

Now I wanted to add a cool HUD to go around the ammo counter and sit above the glowing circles to really complete the look. I jumped into Photoshop and whipped up a little futuristic circle and imported my image to Unity as a new sprite. After attaching it to the Player, I animated it to rotate slowly back and forth. I made sure it moved slow so that it wouldn’t be too distracting.

Here is a look at the rotation animation.

The last task I took on was adjusting my hit boxes to better fit over my Player object. I changed my original circle hit box to three smaller rectangular ones. So far, I haven’t noticed any issues with this method.

Thanks for following along with me so far on this journey! Have a good weekend!

-Myles M.

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