Time.timeScale in Unity
Notes:
Time.timeScale in Unity:
- is used to get or set the scale at which time is passing
- It is used to speed up, slow down or pause; all time based updates
Note: It is recommended that; if you modify Time.timeScale then you must modify the Time.fixedDeltaTime by the same amount
Example Code:
void Start () {
Time.timeScale = 2f;
Time.fixedDeltaTime = Time.fixedDeltaTime * Time.timeScale;
}
void Update () {
this.transform.position += new Vector3 (0f, -5f, 0f) * Time.deltaTime;
}
void FixedUpdate()
{
this.transform.position += new Vector3 (5f, -5f, 0f) * Time.fixedDeltaTime;
}