I am trying to slow down the game temporary when my player picks up a buff item. I am doing it by starting the following Coroutine on collision:
public IEnumerator SlowMo () {
Time.timeScale = StaticVariables.Buff_SlowMo_Speed;
Overlay_SlowDown.SetActive(true);
Time.fixedDeltaTime = StaticVariables.fixedDeltaTime * Time.timeScale;
yield return new WaitForSecondsRealtime (StaticVariables.Buff_SlowMo_Duration);
Time.timeScale = 1;
Time.fixedDeltaTime = StaticVariables.fixedDeltaTime * Time.timeScale;
Overlay_SlowDown.SetActive(false);
}
StaticVariables holds
public static float Buff_SlowMo_Speed = 0.5f;
public static float Buff_SlowMo_Duration = 1;
The problem is, nothing after the yield function is triggered, and I have no idea why. Timescale does not return to normal and the overlay game object does not get disabled.
I am using the timescale manipulation code from the unity examples. I honestly have almost no experience with the timescale manipulation and would be very grateful if someone pointed out the (probably quite dumb) mistake I am making.