- Home /
Question by
zwnophoria · Jul 07, 2013 at 09:27 AM ·
javascriptguiprogress barhealth
Health bar only updates on character death
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;
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613105621im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Setting Scroll View Width GUILayout 1 Answer
Can't move GUI 1 Answer
Please help me make a health system with GUI. I cant do it! 3 Answers
LoadLevel Health Question. 1 Answer