Time.timeScale is always equal to 1

I have a character that slows down time whenever the player presses the X key and reset the timeScale back to 1 whenever they release the X key.
The method that slows down the time and resets it is being called correctly;

void Update() {
    if (InputGetKeyDown(KeyCode.X)) SlowMotion(true);
    if (InputGetKeyUp(KeyCode.X)) SlowMotion(false);

    Debug.Log(Time.timeScale);
    Debug.Log(Time.fixedDeltaTime);
}
void SlowMotion(bool _timeState) {
    if (_timeState) Time.timeScale = 0.5f;
    else Time.timeScale = 1f;
    Time.fixedDeltaTime = Time.timeScale = 0.02f;
}

When i press X, the console displays 1 and 0.004 and when i release, it displays 1 and 0.02
for some reason the timeScale is always resetting but fixedDeltaTime is updating correctly

Line 11 above assigns 0.02f to both Time.timeScale, then to Time.fixedDeltaTime, always overwriting whatever you set before that.

2 Likes