2D Animator Speed change through code

My Animator has an Idle animation and a Walk animation.

I can cache the Animator easily and use all the helpful commands associated with that component.

However, I want to change the speed of one of the walk animation through code, and no matter what, I always get the “Animation is not attached” error.

After googling I have tried:


None work. I cant find any more help. I feel like there is a component I’m missing that I need to cache to use this speed changing functionality but I can find it anywhere in my searching.

Also I am not using a mechanim, simply 2D sprites, and google is surprisingly not helping me with this at all.

I really hope you can help! :slight_smile:

I’ve also had this problem with setting the speed of an animation related to an animator. The only way I’ve been able to change the speed of the animation is to use a animator.speed = somefloat.

This gives me the impression animator.speed overrides the animation speed. Since I have been able to set a basic animation speed the ways above.

Not quite an answer but hope it helps