/// <summary> /// This checks for exit conditions (player reaches final destination or time is up) /// </summary> void CheckForExit() { if (game && timeStarted) // if game and time both are started then { currentTime = Time.time; float time_difference = currentTime - initTime; //store the difference of time timer.text = "Time : " + time_difference.ToString("0.00") + "s"; //display time in the text box if ((time_difference) > 60) //if time difference is greater than 60s, change the scene { DisplayScore.getTimeValues(time_difference); //send time values to Display score timeStarted = false; //assign time started as false SceneManager.LoadScene(4); //load display score scene } } float distance = Vector3.Distance(transform.position, spotlight.transform.position); if (distance <= 5.0f) //if user is near the final position { timeStarted = false; if (game) //if in game mode { DisplayScore.getTimeValues(currentTime - initTime); SceneManager.LoadScene(3); //load question answers scene } else { SceneManager.LoadScene(0); //if loses load main menu scene } } }