Animation Legacy Won't Play

Hi everyone, i’m a newbie so please help me, i’m using Legacy Animation, i added Animation Component to my Character and here is my code:

publicvoid damage(int dame)
    {
    playerhp = playerhp - dame;
    rb2d.AddForce(Vector2.up *400);
    gameObject.GetComponent<Animation>().Play("Stunt");
    }

when my Character being damaged it’s should start playing that Stunt animation but it won’t

If you don’t add an animation component to your object BEFORE you record the animation, it will automatically add the component but also will try to add an ANIMATOR component and likely has ‘root motion’ switched on which interferes.

If I remember rightly (unless they fixed this) you have to add an ANIMATION component to your object first, and THEN record your animation clip, and then assign the clip to the animation component manually, otherwise the new animation system sort of interferes with things. At least that’s how I understand it.

1 Like

I did as you say but the Animation still not playing, thanks for your reply anyway

Did you notice that “publicvoid” is meant to have a space in it in your sourcecode above? Or was that just a copying error? Do you get any editor errors? Do a Debug.Log(‘works’); right before the play command to make sure the program is flowing into that code.

1 Like

It’s actually have a space, i don’t get any editor errors, i used Animator and it’s work just fine but i would love to use Legacy Animation, this is so hard

Any Ideas, please ?

I seem to remember something about going to the animation clip in the inspector, then at the top of the inspector window there’s some little dropdown with an option to ‘debug’, and then it will show you some data fields, and one of those I think is a checkbox to say that the animation is ‘legacy’. … try that and see that it is checked. And then see if it works better?

1 Like

Tried that too, but still nothing happened

does the add force, in that function, work? does the player move up?

1 Like

Everything work fine except Animation with legacy type, oh man, i think i won’t use legacy anymore

Someone knowledgeable please help this fellow?

1 Like

thank you, i’m very appreciate your help