so whenever my character has hit an object, it slows the time by 0.5f, then slowly brings the time back to 1f within the span of 5 seconds, then the scene will reload. The problem is, whenever the scene has been reloaded, the deltatime is still slowed down by 0.5f, and not returning to normal, any solutions?
here is the script on my gameobject responsible for slowing, and fast forwarding the time
{
public float slowdownFactor = 0.05f;
public float slowdownLength = 2f;
void Update()
{
Time.timeScale += (1f / slowdownLength) * Time.unscaledDeltaTime;
Time.timeScale = Mathf.Clamp(Time.timeScale, 0f, 1f);
}
public void DoSlowmotion ()
{
Time.timeScale = slowdownFactor;
Time.fixedDeltaTime = Time.timeScale * .02f;
}
}