Slow down time but my player object doesnt return to normal speed.

So basically, i tried to make a slow down script for my player and the world and then the speed should return to normal speed, and it seems like it does for less than a second but then just continues to slow down. (also im a coding fetus)

using UnityEngine;

public class TImeManager : MonoBehaviour {

public float slowDownFactor = 0.05f;
public float slowDownLength = 1f;

void Update()
{
Time.timeScale += (1f / slowDownLength) * Time.unscaledDeltaTime;
Time.timeScale = Mathf.Clamp(Time.timeScale, 0f, 1f);
}

public void slowDown()
{

Time.timeScale = slowDownFactor;
Time.fixedDeltaTime = Time.timeScale * .02f;

}

}

if anymore context is needed just tell me sorry i dont know much :confused:

Keep copies of original timeScale and unscaledDeltaTime values somewhere so you can reset them when the “slow down” stops, maybe?

You’re never resetting Time.fixedDeltaTime back to normal, only Time.timeScale. (Also you’re not setting fixedDeltaTime to an appropriate number.)

oh okey, well ill need to fix that then, thank you!

ok, ill try that, thank you