I want to make a health bar. It consist of the 10 different JPEG images (0hp, 10hp, 20hp …). But when I’m getting damage, it loads incorrect (screenshoot). Right part of the health bar should be white.
var playerHealth00 : Texture2D;
var playerHealth10 : Texture2D;
//...
var playerHealth100 : Texture2D;
var HEALTH = 100;
function Update()
{
var g_Health = gameObject.Find ("GUIHealth");
if(HEALTH > 90)
g_Health.guiTexture.texture = playerHealth100;
else if(HEALTH > 80)
g_Health.guiTexture.texture = playerHealth90;
//...
else if(HEALTH > 0)
g_Health.guiTexture.texture = playerHealth10;
else
g_Health.guiTexture.texture = playerHealth00;
}