I need to yield for the length of my animation that is in the base layer and named "TurnAround". It makes the character display an animation of them turning around. How do I get this turnaround? Then How do I get the time length?
Is Turnaround an AnimationState? Is it an AnimationStateInfo? It is one of the animations in Animator with transitions.
I have anim = GetComponent<Animator>();
to get the Animator. I'm looking at turnAround = anim.getCurrentAnimatorStateInfo
but don't think that is quite right.
Thanks
It is under AnimationClip
.
Get it calling:
float length = gameObject.animation.clip.length;
EDIT
Since you are using an animator, you can do this:
Animator animator = GetComponent<Animator>();
float length = animator.animation.clip.length;
Animator
inherits Animation
, you can call of Animation
's members.
EDIT 2
Here is the final way that will definitely work:
Animation turnBack; //assign in inspector
...
float length = turnBack.clip.length;
turnBack
goes at the top so it is a global variable, then you assign the animation to it in the unity editor (inspector). You can also do this with an array of animations and reference them by their index
Animation[] animations = new Animation[max];
float length = animations[index].clip.length;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.