Unity thinks my animation is not attached, but it is.

I am currently trying to make a soldier play an animation for a third person view for my multiplayer game. I had just imported the BootCamp soldier in for a placeholder, along with all the animations. In my script, I had wrote:

anim.animation.CrossFade("Standing");

And apparently the Unity Console tells me the animation ‘Standing’ is not attached to the anim GameObject, but it clearly is. The complete error is the following:

The animation state Standing could not be played because it couldn't be found!
Please attach an animation clip with the name 'Standing' or call this function only for existing animations.
UnityEngine.Animation:CrossFade(String)
MultiplayerMulti:UpdateAnimations() (at Assets/_Scripts/MultiplayerMulti.js:56)
MultiplayerMulti:Update() (at Assets/_Scripts/MultiplayerMulti.js:35)

MultiplayerMulti line 56 is just the line I had provided above.

As you can see, it is CLEARLY attached to my Soldier object. And yes, the soldier object IS SET AS THE GameObject for the anim variable! Any idea what the real problem is is appreciated.

Thanks in advance,
william9518

Probably the question description is still unclear whether you are directly using the object or instantiating the object . However, there are several possibilities in your case. First, in the image you are showing is the prefab of the soldier on which the animation is attached. Check whether the object which is placed in the scene i. e. the hierarchy, the animation is attached to it or not. If not then you probably need to redrop the object. If it doesn’t work then you need to instantiate the object through code.

It is showing you the error just because the object present in the hierarchy doesn’t have the animation file attached to it. Do one thing, place your object in the hierarchy from the project window, check whether Animation is attached to it, use that object as a reference through the script and instantiate that object. It would definitely work.

I fixed it by not doing it at all. I revamped the system with Animators.