# Slowing animation to the correct speed.

I am making the player hit faster as they level up. I can’t seem to get the right animator speed to sync with the amount of time that the animation is supposed to play. Here is the roll animation. I am trying to get the roll to finish executing at 1.5 seconds. I am trying to adjust the animator speed to account for this.

``````animator.Play("Roll");
float length = animator.GetCurrentAnimatorStateInfo(0).length;
rollTime =1.5;
animator.speed = rollTime / length;
``````

Let’s say the length is 2;

My reasoning is the that when speed is one, length will play out in .416 seconds. So if length is 2…
.416 / 1 = 2 / x → x = 2 / 0.416
Then I use x as the speed multiplier. What am I doing wrong?

Here I just adjusted the time until it looks right.

If you double rollTime, you’ll double the animator speed. I think you want to halve the speed!

You want `length / speed = rollTime`, so `speed = length / rollTime`.

You mixed up the order of `length` and `rollTime`. I think your example has the order correct?

Yep, thank you both it’s working now!