Question by
unity_nLQv3d4b4WSlaw · Apr 22, 2019 at 08:44 PM ·
inputfunctionbooleantime.deltatime
Game crashes when function is triggered,
now the goal was to make a boolean true by pressing a key once. by turning this to true it would run the function until either the timer hit 0, or the button is pressed again. now what happens is that the game crashes as soon as i hit E.
if (Input.GetKey(KeyCode.E))
{
keyOn = true;
{
timerTrigger();
}
}
public void timerTrigger()
{
while (keyOn == true)
{
spawnWait = 0;
TimeAttack.text = timeLeft.ToString();
timeLeft -= Time.deltaTime;
if (timeLeft < 0)
{
gameover();
}
}
}
Comment