Why Isn't my Animation Recognized?

Hai! So I have a script that calls an animation under a condition. It will play every other animation but this one. Here’s the error:

The animation state Fichen_Hit could not be played because it couldn't be found!
Please attach an animation clip with the name 'Fichen_Hit' or call this function only for existing animations.
UnityEngine.Animation:Play(String)

Here’s the line it’s referring to:

transform.Find("Fichen").animation.Play("Fichen_Hit");

and here’s proof I added the animation to the component:

10367-answers4.png

But why would it still not work if I have everyone set up right just like my other animations?

1 Answer

1

I’m not sure but I guess you either finding your object wrong, or you are not accessing component right, try this way:

C#:

GameObject.Find("Fichen").GetComponent<Animation>().Play("Fichen_Hit");

JS:

GameObject.Find("Fichen").GetComponent(Animation).Play("Fichen_Hit");

I tried what you did but It will still come up with the same error...It's really weird it doesn't do that with the other animations.

Are you sure that animation works at all? Have you tried setting "Fichen_Hit" animation as first default animation with "Play Automatically" and see if animation is playing at all?

Hmm it's weird if I add it not as a default but the animation works fine in the preview also I can't really test the default because of some new animator controller component. Should I try using a controller?

You know what I've noticed? My Fichen_Hit prefab has some avatar attached? Would that be a problem if I connect it to older animations?

Try changing on your model in "Rig" section from Animation Type: Generic, to Legacy.