Hello all,
I’m a PhD student and I’m doing a simple game of collecting coins for my research. The question might be silly but I’m not a programmer. I’m trying to keep and add score in every level, but when the new scene is loaded the score starts again from the zero.
My code so far is:
static var score=0; var guiScore :
GUIText;
function start () {
guiScore.text = "Coins: "+score;
}
function OnTriggerEnter (other :Collider )
{
Debug.Log ("OnTriggerEnter () was called");
if (other.tag == "Coin") {
Debug.Log ("Other object is coin");
score ++;
Debug.Log
("Score is now " + score);
Destroy (other.gameObject);
guiScore.text = "Coins : " +score;
Timer.onpause = true;
Application.LoadLevel("Menu2");
}
}
I would really appreciate any help.
Thanks in advance.