I have a problem I can not solve. I want my score to be saved and they are saved to the highest score. These are my 2 scripts .js
//stores score
var trova : Transform;
var miaPos : Transform;
static var nuovoPunteggio;
static var preleva;
function Start () {
}
function Update () {
var trovaDistanza : float = Vector3.Distance(miaPos.position,trova.position);
if(trovaDistanza <=4.0){
Save(Score.score);
Application.LoadLevel("GameOver");
print("Il punteggio di questa partita è :" + Score.score);
}
}
function Save(punteggio:int){
PlayerPrefs.SetInt("punto",Score.score);
//print(punteggio);
}
//read score
#pragma strict
var savedScore:int;
var nuovoPunto : int;
function Start () {
savedScore = PlayerPrefs.GetInt("punto",Score.score); //ultimo punteggio
//print("PUNTEGGIO OTTENUTO: " + savedScore);
if(savedScore > nuovoPunto){
nuovoPunto = savedScore;
print("IL PUNTEGGIO PIU' ALTO E': "+ nuovoPunto);
}
}
function Update () {
}
function OnGUI(){
GUI.Label (Rect (10, 10,200, 200), "Punteggio partita: " + savedScore);
GUI.Label (Rect (10, 50,200, 200), "Record punteggio: " + nuovoPunto);
}