Hi guys. I have a question. I have made a healthbar scenter code hereript using JavaScript. However, even though my debuglog shows my damage taken and I can see visual changes when I set my enemy damage really high, how can I edit my script to display damage taken over time, not just display 0hp when the playerhealth is empty?
I will attach my script below:
#pragma strict
var hpBar : GUIStyle;
var bgimage : Texture2D;
var fgimage : Texture2D;
static var hpDamage : int = 3;
static var playerHealth = 100.0;
function Update(){
}
function Start(){
}
function OnGUI(){
GUI.BeginGroup(Rect(10,10,256,32));
GUI.Box(Rect(0,0,256,32)bgimage,hpBar);
GUI.BeginGroup(Rect(0,0,playerHealth*256,32));
GUI.Box(Rect(0,0,256,32),fgimage,hpBar);
GUI.EndGroup();
GUI.EndGroup();
}
static function Enemy1Attack1(){
playerHealth -= hpDamage;
}
can you edit your question instead of posting a comment? Also can you format your code in the question, so it's readable? If so I can probably answer your question :)
– Benproductions1you're welcome :)
– Seth-Bergman@Seth-Bergman Damn having Karma is cool :P @paradoxxx GUI.BeginGroup does nothing with the width, it only changes the origin, so doing the
– Benproductions1playerhealthwidth thing with theGUI.Boxis the way :)