I’m participating in a Game Jam and made a Time Slow Powerup for the game. It was working, untill I added some new code and started crashing. The problem is, even after commenting it out, it still crashed.
You should know that I am using Unity 2019.4.17f1.
This is the Time Slow code:
void Items()
{
if(Input.GetKeyDown(KeyCode.T) && timeRecharged)
{
timeCanCancel = false;
StartCoroutine(TimeSlow());
while (timeIsSlow)
{
if (Input.GetKeyUp(KeyCode.T))
{
timeCanCancel = true;
}
if (Input.GetKeyDown(KeyCode.T) && timeCanCancel)
{
StopCoroutine(TimeSlow());
Time.timeScale = 1f;
timeIsSlow = false;
StartCoroutine(TimeCancel());
}
}
}
}
IEnumerator TimeSlow()
{
timeRecharged = false;
Time.timeScale = timeSlowAmount;
timeIsSlow = true;
yield return new WaitForSeconds(4f);
Time.timeScale = 1f;
timeIsSlow = false;
yield return new WaitForSeconds(7f);
timeRecharged = true;
}
IEnumerator TimeCancel()
{
yield return new WaitForSeconds(4f);
timeRecharged = true;
}