How to Lerp or Slerp Time.timeScale change

Hello,
I want to have a smooth transition between,

time.timeScale == 1.0
and
time.timeScale == 0.8

How would I go about doing this in JavaScript?

Thanks Daniel

This is a tricky problem. The issue is that typically ‘Time.deltaTime’ is use in some form as part of a Lerp(). But here ‘deltaTime’ will be changing as you change Time.timeScale. One imperfect solution is to grab an arbitrary deltaTime and use that. Sample code:

#pragma strict

private var myDeltaTime : float;
private var speedup = false;
var maxTimeScale = 8.0;
var speed = 4.0;
 
function Start() {
    myDeltaTime = Time.deltaTime; 
    Debug.Log(myDeltaTime); 
}
 
function Update() {
	if (Input.GetKeyDown(KeyCode.A))
		speedup = true;
	
 	if (speedup) 
 		Time.timeScale = Mathf.MoveTowards(Time.timeScale, maxTimeScale, myDeltaTime * speed); 
}

This code speeds up Time.timeScale when the ‘A’ key is pressed.