Unity Freezing on Play

I press the play button and it freezes. No infinite while loops, no bugs, no problems.

With this amount of information, a concrete solution is impossible.

But here a couple of generic tips how I approach issues like that:

  • First and foremost, inspect your editor.log. 99% of the time, you see something useful there. The editor log is at C:\Users\AppData\Local\Unity\Editor\Editor.log
  • Delete ALL your scripts (backup before, of course). Then try again. does it still freeze? If so, submit a bug report. If not, start adding scripts (in a way to keep the code compiling) until you found the freeze
  • Instead of deleting all your scripts, delete all gameObjects in the scene. Then start adding them again. (Its a bit more cumbersome, as “re-adding” probably means “copy the old scene back and delete less objects”)
  • Start inserting Debug.Log(“1”), "Debug.Log(“2”) … all over the place. Then run again and inspect the editor log. That gives you an idea until what place the game came before freezing.

Hope you find the problem.

I actually fixed it, for some reason my variables are messed up, don’t know why. Because of this the while loops were broken and the variables are still messed up and I can’t find the reason. In the part where the game checks if the player should regenerate energy the statements are not fulfilled but it’s still doing it. Any clue whats causing this ?