Problem adding individual clip speed

I’ve been trying to figure this out for hours now and i can’t get it right :C

I have the player object which has an animator which has the controller. In this object i have about 3 different animations and i want to change the speed of one of them.

i know i can do something like: animation[“swing”].speed = speed; but that gives me an error saying that there is no animation attached to player object.

i have one reference to the animator: anim = GetComponent();
and if i do anim.speed = speed; that does increase the speed but to every single clip. So how can i change the animation speed of one single clip?

Thanks in advance!

Sorry to necro a thread. But in case others find this thread like me.

Meat’s answer is good. But it also speeds up all the animations on that particular layer.

Unity came up with a solution (finally) after a couple years.

sharing is caring

Yes, use

if( animator.GetCurrentAnimatorStateInfo(Layer).IsName("yourAnimation"))
      animator.speed = animSpeed;

Where Layer is the animation layer as int and animSpeed is a float to determine animation speed, where 1 is normal.

This way you can set individual speeds for individual animations.

I’ve never tried it though, I just whipped it up today to answer the same question from about 5 different people :smiley:

So, you saw it here first :stuck_out_tongue: maybe :smiley: