Unity crashes when using while loop
I don't know what's happening. As soon as the function is called, unity freezes and I have to use task manager to close it.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class QTEController : MonoBehaviour
{
System.Random random = new System.Random();
public float difficulty;
void Start()
{
difficulty = 0.3f;
}
void Update()
{
if (Input.GetKeyDown(KeyCode.S))
{
oneSimple(true, 0);
}
}
public void oneSimple(bool quick, float localDifficulty)
{
Debug.Log("started");
int num = random.Next(0,26); //creates a random character
char pressKeyC = (char)('a' + num);
string pressKey = pressKeyC.ToString();
float randomizer = Random.Range(0.0f, 1.0f)
if (randomizer > (difficulty*localDifficulty))
{
Debug.Log(pressKey);
bool finished = false;
while (finished == false)
{
Debug.Log(finished);
if (Input.GetKeyDown(pressKey))
{
finished = true;
Debug.Log("done");
}
}
Debug.Log("done2");
}
}
}
Please help! Thanks
Comment