Hello, I need help with a health script. I am making a game much like battle bears in the way of game play and i am trying to make it say how much health you have in numbers instead of a health bar. I am trying to do this by modifying the standard scripts (like fps player) that come with unity and I dont know how to do this. Please help! (screenshot attached)[/img]
so basically like this
var health = 100;
var hp = “”;
hp = “” + health;
then you put like a label
Gui.Label( Rect(0,0,50,50),hp);
of corse you have to do the math but this will basically display the health in numbers
I’m not really shur what your doing or if were even talking about the same thing. i need to take the current health bar and turn it into a gui text that displays the health using the scripts that come with unity.
var health = 100;
var hp = "";
function update (){
//health = health - attack; //this is just simulateing an attack and a decrease in the health
hp = "" + health; //this part basically takes the health and converts it into a string to use in a text
}
function OnGUI() {
GUI.Label (Rect (800, 20, 200, 20), hp); //this displays your health
}
Im basically just showing you how to convert the amount of health you have and display it as text like numbers.
so is this its own script that is attached to the health guitext prefab or is it added on to another script?
You must make your own script, your own custom component to do that.
And something very alike to unitrix suggestion.
how