I am creating a real time multiplayer game in Unity 3d. When a game ends I set a static boolean value called "waitingToEndGame" to true. In Update() it waits a few seconds before moving to a new scene like this:
if (waitingToEndGame)
{
waitTime += Time.deltaTime;
if (waitTime >= 5f)
{
showGameScores = false;
waitingToEndGame = false;
if (type == "Multiplayer") MultiplayerController.Instance.LeaveGame();
GameObject levelManager = GameObject.Find("Level Manager");
levelManager.GetComponent<LevelManager>().LoadLevel("MainMenu");
}
DisableAllMovingObjects();
}
My problem is that even though I am setting the boolean value to true it acts as if it doesn't change and it doesn't make it into the code above to move to the main menu. I even had debug statements printing here as well and they seem to just suddenly stop.