Friday, November 13, 2015

Health HUD Update

The health bar is finally working now, so each time the player gets hit the bar goes down. After showing the health script to the lead programmer, there were a few things that needed to be fixed:
  • The script has to be applied to the game manager
  • Referencing from one script to another
  • Rearranging some of the codes in the health script 
  • Changing the float variables to integers in the game manager
As we were solving the situation, we set the maximum health to five instead of a hundred and managed to get Unity to track the character's health. When the game was running, the number appeared on the console and decreased for every damage that was taken. However, the health bar still didn't go down. Eventually, we managed to get the health bar working and the screen blinks red for every damage taken. It took us an hour and a half to get the health bar to decrease for every hit has been taken.

After solving the situation, I adjusted the health HUD by scaling and changing the color of the bars. It turns out that there are two layers, a background layer and a fill layer. I scaled the width of the background layer and filled it with red while the fill layer is green. It looks very amazing while the game is running. 

Before


After


Credit goes to the Unity tutorial for the health HUD and script videos along with the scripts themselves. Here's the link: https://unity3d.com/learn/tutorials/projects/survival-shooter/player-health?playlist=17144

No comments:

Post a Comment