- Home /
Unity Freezes after restarting level a few times
Hi, when my player dies a window appears to either play again or main menu, when i press play again it works fine and the level starts from start but after i play again 3 more times the unity editor freezes and i have to force quite unity, it always freezes on the 4th time that i play again. I am using Apllication.LoadLevel to restart the scene. Any ideas why this could be happening?
Copy your restart script here. Unity mostly freezes when it encounters an infinite loop, so I guess if it only happens at the 4th time, you either have an infinite loop which activates at the 4th try, or you parallely load the maps and after the 3rd load, unity can't handle the 4th one. But that's just blind guessing here.
i tried commenting out the lines as you see still same problem.
public Canvas deathScreen;
// Use this for initialization
void Start ()
{
//Event$$anonymous$$anager.PlayerDeath += new Event$$anonymous$$anager.GameEvent(PlayerDeath);
//deathScreen.gameObject.SetActive(false);
}
void PlayerDeath()
{
if (deathScreen != null)
{
//deathScreen.gameObject.SetActive(true);
}
}
// Update is called once per frame
void Update () {
}
public void PlayAgain()
{
Application.LoadLevel(Application.loadedLevel);
}
Try
if(deathScreen)
ins$$anonymous$$d of != null
Have you tried $$anonymous$$imizing your game scene and paying attention to the gameObjects after your map restarts ? $$anonymous$$aybe a gameObject duplicates/triplicates/quadriplicates which could cause the problem
Answer by Grysa · Sep 28, 2015 at 12:32 PM
Found the problem myself, basically in a script where i generate platforms i send each one to another script for a chance of a power up to appear on it, basically that was cousing the problem somehow so i just need to work around that.