How do you fix infinite loops
These are the different game states
void Update ()
{
switch (_currentState) {
case GameState.start:
Debug.Log("Start");
_currentState = GameState.inGame;
break;
case GameState.inGame:
//Debug.Log("In Game");
_scoreText.text = "Score: " + _score;
break;
case GameState.gameOver:
Debug.Log("Game Over"); _scoreText.enabled = false;
_gameOverText.enabled = true;
break; }
}
}
This loops seems to be causing unity to crash
while (GameManager.gameManager.CurrentState == GameManager.GameState.inGame)
{
Debug.Log("Enter Lop");
transform.position = Vector3.Lerp(targetPoint1.position, targetpoint2.position, time);
if (Input.GetKey(KeyCode.Space))
{
GameManager.gameManager.CurrentState = GameManager.GameState.gameOver;
}
}
I have aa means of breaking out of the loop so I'm not sure why unity is crashing