No one answered it.
Scene freezes when I restart level
So basically in my script, I am showing the player an intro when he first loads the level. It doesn't show again when he resets the scene or comes back to the level, because that information is redundant. However, when I restart the scene in my game, the camera freezes and the game is not playable. I think it is a problem with the Time.timeScale and how I pause and unpause the game, but I cannot find what is wrong. The PlayerPref "retrys" is set up when you load the game, so don't worry about its initialization.
void Start()
{
intro.enabled = false;
intro2.enabled = false;
Timing.RunCoroutine(SetUp());
}
IEnumerator<float> SetUp()
{
yield return Timing.WaitForSeconds(4.5f);
//disable and enable the UI as appropriate
intro.enabled = true;
intro2.enabled = false;
inGame.enabled = false;
pauseMenu.SetActive(false);
PlayerPrefs.SetInt("levelCurrentlyOn", 1);
//pause the game to allow time to read the information
Time.timeScale = 0;
//stop displaying the welcome information if not the first load of the level
if (PlayerPrefs.GetInt("retrys") > 0)
{
intro.enabled = false;
intro2.enabled = false;
inGame.enabled = true;
pauseMenu.SetActive(true);
Time.timeScale = 1;
}
PlayerPrefs.SetInt("retrys", 2);
}
public void NextPress()
{
//move to the second slide of information
intro.enabled = false;
intro2.enabled = true;
}
public void DonePress()
{
//when done reading, start the game
intro2.enabled = false;
inGame.enabled = true;
pauseMenu.SetActive(true);
Time.timeScale = 1;
}
}
Follow this Question
Related Questions
Restarted scene not working properly 0 Answers
Ios Build freezes when i click a button to switch Scenes 1 Answer
Build freezes IOS on startup. Forced to hit powerbutton 0 Answers
Is true async scene loading possible? 0 Answers
freezes on play 0 Answers