Animator - check when the animation is finished

Hey!

I got a Animator tree that is like this:
Walk ↔ Attack 1 ↔ Attack_1_rest → Walk
What I’m trying to do is to make the attack do damage when the animation is finished or maybe in the middle of the animation - depends on the character and animation.
I know how to make the character do damage and such, but I don’t know how do for example this “fantasy” Script:

if (animation_is_finished == true) {
"Booom do damage"
}

I have searched and all the examples I can find is a bit overwhelming for me sadly… I don’t necessarily need the solution, It would be enough getting on the right track by some links and such. I have checked the handybook already, but not sure what to do :expressionless:

Cheers :slight_smile:

Given:
Animator anim;

this.anim.animation.IsPlaying(“Clip Name”) // returns a boolean

Check the documentation: Unity - Scripting API: Animation.IsPlaying

Answers above seem to be fine, but for some reason they don’t work for me.

I am using AnimationEvent method.

1 Like

Thanks to everyone that suggested ideas! I ended up using Elmar1028’s suggestion because then I can just do a check inside of the animation like for example:

     void DoDamage1(int do_attack_1 )
    {
        Enemy_1_Health -=3;
    }
1 Like