Thursday, 26 March 2015

Unity HUD:


I began by doctoring a section of Reece's menu border, in order to create some coherency throughout the game, into a Healthbar border in photoshop. I created a canvas on the main camera within Unity, and after turning the border into a sprite, attached the border to it.


I then duplicated Reece's score counter, and reformated it to read out the players health and attached this through parenting to the border, i did the same for the grey background to the healthbar.


I duplicated the health bar background, and turned it green for the moving component of the healthbar.


I created a mask on the grey background, so that when i wrote the script, which would move the healthbar along its X axis, the portion of the green bar protruding to the left would be invisable.


For the coding itself, i followed a youtube tutorial which used a formula to determine a -10 to 0 to +10 scale along the health bars length, using 0 (the furthest left edge of the bar) as the starting, full health position, -10 as the fully depleted, dead position, with 10 being the overal length of the bar indicating full health when the bar was at 0. This was paired up to Georges health scripts where a value of health between 0 and 100 would correspond to a value between -10 and 0 to determine the bars position. I also added the color change of the bar, so that as the health moved between 0 (full health) to -5 (50% health) the green value of the bars RGB would stay at 255, while the red value would climb from 0 -255, then once the player fell below 50% health, the red value would remain at 255, while the green value would fall from 255 - 0, creating the transition from green, to yellow, to orange, to red according to the proportion of health lost. i linked the text element of the health bar and resulted in a health bar that would fall and rise as the player lost, and then regained health, along with matching numerical feedback, and colour indicator.

No comments:

Post a Comment