I’ve got my health bar to appear, and it works… except that it doesn’t seem to update itself until my character dies.
I’ve already tried searching through the already existing answers on the forum, but none of it really helped much but confuse me further. The furthest i got was from here, which basically told me that I had to read up on how to access variables and functions on other objects. But that link is dead, and I am stuck.
This is what i have currently:
var sizeBar: Vector2 = new Vector2 (500,150);
var emptyBar: Texture2D;
var fullBar: Texture2D;
var barDisplayer: float;
function Start() {
BarDisplayer = 1;
}
function OnGUI() {
GUI.BeginGroup (new Rect(0,0, sizeBar.x, sizeBar.y));
GUI.Label (Rect (0,0, sizeBar.x, sizeBar.y), BarHolder);
GUI.BeginGroup (new Rect (0,0, sizeBar.x * BarDisplayer, sizeBar.y));
GUI.Label (Rect (0,0, sizeBar.x, sizeBar.y), BarCharger);
GUI.EndGroup ();
GUI.EndGroup ();
}
function Update() {
BarDisplayer = health;
}