I’m trying to have my game speed up over time, the game starts at stage1 speed, after a period of time should progress to stage 2 speed and then stage 3 speed. I seem to be having an issue getting the game into stage 3. But I can get the game into stage 2, the code I have is as follows, I cannot understand why the debug.log will output stage2 but never stage3, can anyone help.
Also the console continuedly outputs “stage1” even when stage1active is set to false
float timer = 0f;
private void Update()
{
timer += Time.deltaTime;
if(timer < 10f)
{
stage1Active = true;
}
if(timer > 10f && timer < 20f)
{
stage2Active = true;
stage1Active = false;
}
if(timer > 20f)
{
stage3Active = true;
}
if (stage1Active)
{
speed = 2f;
Debug.Log("Stage1");
}
if (stage2Active)
{
speed = 8f;
Debug.Log("Stage2");
}
if (stage3Active)
{
speed = 25f;
Debug.Log("Stage3");
}
}