- Home /
Question by
oinkoinkflapflap · Feb 19, 2011 at 09:37 PM ·
guicolliderontriggerenterhealthbarpercentage
percentage health bar
hi, is there a way to make a GUI percentage health bar? i have the script to lose health is there a way to make it start at 100% and go down 10 on every OnTriggerEnter that collides with my tag "evil shot" thanks all!!!
var Health = 100;
static var dead = false;
function Update() {
if (Health <=1)
{
dead = true;
}
}
function OnTriggerEnter(hit : Collider){
if(hit.gameObject.tag == "evil shoot")
{ Health -= 10;
Destroy(hit.gameObject);
}
}
function LateUpdate()
{ if(dead)
{
transform.position = Vector3(3386.499,211.0097,707.7693);
dead = false;
}
}
Comment
Answer by AppTechStudios · Feb 19, 2011 at 09:54 PM
So you need to translate the numbers into a health bar? This video should help:
http://www.youtube.com/watch?v=iER_LFwi1-U
Good luck!
-Robert
NOTE: I did not make the video.