- Home /
Get Animation from Animator
I have been at this for hours. I have read roughly a dozen questions (and answers) across several sites. I cannot figure this out!
I have my Animator, but I cannot get any of this Animator's animations. Ideally, I want to be able to get the Animation by its name, not by which is actively playing. I am trying to find something like this:
Animation myAnimation = myAnimator["Name of Animation"];
Pretty much all the info I have come across assumes people already have the Animation, so I must be missing something obvious.
If I use animation["Name of My Animation"];
, then it gives me some error saying that Animation is not attached :-/
How can I get a specific Animation from the Animator?
Answer by synchro_suban · Feb 24, 2018 at 12:44 PM
Something very simple that works for me
float timeOfAnimation = GetComponent<Animator>().runtimeAnimatorController.animationClips[0].length;
Ah, clean, simple and easy to understand!.. Great job, thanks!
This doesnt get an Animation, it gets an AnimationClip. They are different classes.
that is true, found any way to get the Animation?