Play animation at variable speed

Hello,

I try to play an animation of several characters and a ball at variable speed. I want to stop it at the beginning and use the alphanumeric keys to adjust the speed.
key 5 = normal speed = 1
key 4 = 0.5
key 3 = 0.25
key 2 = 0.12
key 0 = 0 or stop
After the stop, the idea is to play again from the point where I stop.

If you want to simulate slow motion, try Time.timeScale.

If you prefer to keep the timescale the same, you may need to look up AnimationState.speed.

Thanks getluky,

It is better for the project to use Time.timeScale
I want to activate the speed by pressing one of the 123456789 of the numeric keypad.
Is the following code correct and to apply to the characters group ?


function Update () {
if (Input.GetButtonDown ("5")) {
Time.timeScale = 1;
}
if (Input.GetButtonDown ("4")) {
Time.timeScale = 0.5;
}
if (Input.GetButtonDown ("3")) {
Time.timeScale = 0.25;
}
if (Input.GetButtonDown ("2")) {
Time.timeScale = 0.125;
}
if (Input.GetButtonDown ("0")) {
Time.timeScale = 0;
}
else {
Time.timeScale = 1.0;
}
}

What is the correct code for alphanumeric keys ? “1” or “Alpha1” ? It’s not pretty clear in the doc …

Thanks for spend time with a newbie …

Regards,