I made a game where you can run through levels with highscores. And i made one for any level… so the part that isnt working, is the part that saves the highscore to playerprefs… For Level 1 its working but not for the two other ones ;( I compared the level 1 if-statement with the two others and they didnt had anything bad… I dont know whats my fault… Here the if-statement for Level 1:
void OnTriggerExit (Collider player) {
Scene currentScene = SceneManager.GetActiveScene ();
string sceneName = currentScene.name;
float t = Time.time - StartTime;
string seconds = (t % 60).ToString ("f2");
TimerText.text = seconds;
Debug.Log ("Current Scene is: " + sceneName);
if (sceneName == "Level 1" & t < PlayerPrefs.GetFloat ("Record1", 999999) & FINISHTEXT.activeSelf == true) {
PlayerPrefs.SetFloat ("Record1", t);
Record = PlayerPrefs.GetFloat ("Record1", 999999);
RecordText.text = PlayerPrefs.GetFloat ("Record1", 999999).ToString ();
Debug.Log ("LEVEL1 NEW RECORD!");
}
}
And heres the if-statement for Level 2 and three:
void OnTriggerExit (Collider player) {
Scene currentScene = SceneManager.GetActiveScene ();
string sceneName = currentScene.name;
float t = Time.time - StartTime;
string seconds = (t % 60).ToString ("f2");
TimerText.text = seconds;
Debug.Log ("Current Scene is: " + sceneName);
if (sceneName == "Level 2" & t < PlayerPrefs.GetFloat ("Record2", 999999) & FINISHTEXT.activeSelf == true) {
PlayerPrefs.SetFloat ("Record2", t);
Record = PlayerPrefs.GetFloat ("Record2", 999999);
RecordText.text = PlayerPrefs.GetFloat ("Record2", 999999).ToString ();
Debug.Log ("LEVEL2 NEW RECORD!");
}
}