I have this code:
#pragma strict
public var hpPoints : float = 3;
public var CurrentHP : float = 3;
function Start () {
}
function Update () {
var hits;
var maxhits;
hits = GameObject.Find("hitstaken").guiText;
maxhits = GameObject.Find("maxhits").guiText;
hits = CurrentHP.ToString;
maxhits = hpPoints.ToString;
}
function OnCollisionEnter(collision: Collision) {
if (collision.gameObject.tag == "obstacle"){
CurrentHP -= 1;
}
print("You have hit an object. " + "You have " + CurrentHP + "/" + hpPoints + " HP points.");
if (CurrentHP <= 0){
print("You lost!");
}
}
Everything works except the GUI part. They don’t change how they are suposed to change.
I tried to use “hits.text” but it told me that “text” is not a component of something.
Ideeas ?