I’ve looked at questions other people made and I can’t seem to get them to work. I want to save myLives variable to another level. I’ve tried putting DontDestroyOnLoad but I just get a crash when I put it in, I know I’m doing it wrong.
public class Lives : MonoBehaviour {
void OnGUI() {
GUI.Label(new Rect(10, 10, 100, 20), "Lives left: " + myLives.ToString());
}
public int myLives = 3;
public Transform destination;
void OnTriggerEnter ( Collider col ){
col.transform.position = destination.position;
col.transform.rotation = destination.rotation;
myLives--;
}
void Update(){
if(myLives <= 0){
Application.LoadLevel(0);
}
}
}