#Unity crashing because of while

1 messages · Page 1 of 1 (latest)

stable monolith
#
 if(Input.GetKeyDown(KeyCode.Period))
        {
            inTypingMode = true;
        }
        while(inTypingMode)
        {
            Debug.Log("Currently Typing");
            if(Input.GetKeyDown(KeyCode.Comma))
            {
                inTypingMode = false;            
            }
            else
            {
                if (Input.anyKeyDown)
                {
                    Debug.Log("Typing Crap");
                }
            }
        }

was trying to make a typing guessing game and this somehow crash the project, why? since you can exit the while with comma why does it crash?

neat sparrow
#

because it never gets a chance to render a new frame or process anything else

#

Input never updates, etc

#

It just plays the while loop indefinitely

stable monolith
#

but i put it in the void Updae()?

neat sparrow
#

Then you don't even need the while loop

#

Update already runs every frame

neat sparrow