Animator doubt

Is there any way to say in code “until the animation finish”? refering to animator.
In a coroutine you can wait for seconds with (yield return new WaitForSeconds(1f):wink: for example, but I need to wait until the animation finish? How can I do it?

Could I say in code for example: at half of the animation or 0.5 of animation?
I have an animation of attack and i want that when animation goes in half makes the damage.
I know I can do it with Animation but I prefer use Animator, Can I do it with Animator?

Thx

The expected way to do this sort of thing is via Animation Events. If you set an event up in the animation, it’ll call a given function.

I know how to do it in the Animation but can´t I do it with the Animator?

It works the same.

The distinction between the words Animator and Animation mostly only matters in script or when adding components. The Animator component still uses AnimationClip to store its animations, and those are still edited by the Animation window.

So, Have I to put the Animation Component to my character?
ok then it should be something like this:
public AnimationClip attack;

if (mAnima[attack.name].time == 0.8f){

}
Is waiting for this 0.8 of the duration of the animation? If not, Could you write me an example of how to put if(animation is 0.5) and if(animation is finished) please?

Thanks a lot

Get the clip, wait for the length.

You can also get the state hash and wait for it to change, indicating a transition.

1 Like

No. You use the Animator component which uses the AnimationClip class to store animations and the Animation Window to edit the animations.

1 Like

I still dont know how to use “Animator.GetCurrentAnimatorClipInfo”. I have already check both links but I dont know exactly how to use it. Could you make me an example please?

Thanks you <3

Ok,ok sorry didnt know it. Thanks!

Its just a reference to your Animator component. The entire unity api is formatted this way.