title: While loop freezes game in Unity3D
body: <p>I've always struggled with while loops because they barely ever work for me. They always cause my Unity3D application to freeze, but in this instance I really need it to work:</p>
  
  <pre><code>bool gameOver = false;
  bool spawned = false;
  float timer = 4f;
  
  void Update () 
  {
      while (!gameOver)
      {
          if (!spawned)
          {
              //Do something
          }
          else if (timer &gt;= 2.0f)
          {
              //Do something else
          }
          else
          {
              timer += Time.deltaTime;
          }
      }
  }
  </code></pre>
  
  <p>Ideally, I want those if statements to run as the game runs. Right now it crashes the program and I know it's the while loop which is the problem because it freezes anytime I uncomment it out.</p>