OK so i use those two script you can see below for my player’s hearts. How is it possible to make the hearts be minus 1 when i press the Respawn button and the level is loaded? Also, i noticed that some objects that were destroyed at first, were loaded together with the level and i dont really want that. Thanks!
FallDamage.js
var hearts : int = 3;
function OnGUI(){
GUI.Box(new Rect(20,20,100,40), "Hearts : " + hearts);
if(hearts < 0){
hearts = 0;
}
}
TriggerFloor.js
var showGUI : boolean = false;
function OnTriggerEnter(other:Collider){
var otherScript : FallDamage = GameObject.Find("Player").GetComponent(FallDamage);
otherScript.hearts -= 1;
if(other.gameObject.name == "Player"){
showGUI = true;
}
}
function OnGUI(){
if(showGUI){
if(GUI.Button(new Rect(20,70,100,50), "Respawn")){
Application.LoadLevel(Application.loadedLevel);
}
}
}
um anyone?
– WesterlyCarrot9