I have a Healthbar but I want it to change of color.
The HealthBar is decreasing by delta.Time. But I want the HealthBar color is blue and if it has less health, the color will change in red. And if I fill the healthbar with medic Objects, it turns back to green.
By example, if the maximum health is 100 then the healthbar color is green, if it’s 30 then the bar color will change to red.
Someone who can help me?
This is what I got,
static var totalTime = 100.0;
static var remainingTime = 100.0;
var BarBorder:Texture2D;
var BarBorderWidth:float=800;
var BarBorderHeight:float=28;
var Bar:Texture2D;
var BarWidth:float=800;
var BarHeight:float=28;
function Update() {
if (remainingTime > 0.0)
remainingTime -= Time.deltaTime;
}
function OnGUI(){
GUI.DrawTexture(Rect( (Screen.width - BarBorderWidth)*0.5,(Screen.height - BarBorderHeight)*1.0, BarBorderWidth, BarBorderHeight), BarBorder);
GUI.DrawTexture(Rect( (Screen.width - BarWidth)*0.5,(Screen.height - BarHeight)*1.0, BarWidth* remainingTime/totalTime, BarHeight), Bar);
}
This is with guiTextures. But I really want it with colors. Please help