I'm following Mike Geig's infinite runner tutorial but even though the scripts are identical my game over page always says 0 as the score and I don't know why.
this is the game over script where I think something might be wrong
using UnityEngine;
using System.Collections;
public class GameOverScript : MonoBehaviour {
int score = 0;
void Start () {
score = PlayerPrefs.GetInt("score");
}
void OnGUI()
{
GUI.Label(new Rect (Screen.width / 2 - 40, 50, 80 ,30), "Game Over");
GUI.Label(new Rect (Screen.width / 2 - 40, 300, 80, 30), "Score: " + score);
if(GUI.Button(new Rect (Screen.width / 2 - 30, 350, 60, 30), "Retry?"))
{
Application.LoadLevel (0);
}
}
}
↧