- Home /
Changing speed of specific animation state, at runtime
According to Unity 5.1 release notes it is possible to control AnimationState.speed during runtime. I am unable, however, to figure out how to get a reference to an AnimationState during runtime, given the Animator.
Feels like a silly question, but I haven't been able to find the answer anywhere. Any ideas?
Answer by IgorAherne · Jun 07, 2017 at 03:47 AM
Sometimes unity tries to make our life as hard as possible.
You must specify parameter during editor, inside of Animator window, in the Parameters rollout.
On your state you can then assign this parameter to affect speed of that particular state.
You can then change it from code via Animator.SetFloat("yrParameter", speedVar);
Slightly different story if you need this to work in Editor (You have more functionality available):
Animator.SetFloat("yrParameter", speedVar);
to use this as u said I have to assign it in the animator to the state I want BUT, I can't assign it to the speed,, just the Speed$$anonymous$$ultiplier! which if I set to -1 won't exit and will play in reverse for ever !
Your answer
Follow this Question
Related Questions
Can the mecanim animators Controller var be set in code? 1 Answer
Accessing AnimationState in Animator 0 Answers
How to stop mesh disappearing during Animator state transition blend time? 1 Answer
Animation events firing all at once in mirrored blend tree 1 Answer
Animator idle minimal delay 0 Answers