- Home /
Animation State could not be played
The Animation State could not be Played, because it could not be found. Is the error I receive. The tutorial that I'm working on is Survival Island from the Packtpub.Unity.3.x.Game.Development.Essentials (Book) I've gotten half way through it and I don't want want to be a quitter. When I throw a coconut on the target is says "The Animation State could not be Played, because it could not be found." Does anyone know what I should do to resolve this problem?
Answer by Seth-Bergman · May 02, 2012 at 01:13 AM
To elaborate on above answer, it's trying to play an animation by name, like:
animation.Play("hitAnim");
or just
animation.Play(); (if the object only has one anim, I guess)
So, it can't find the anim in question, which means there is no animation with that name attached to the object in question. (If the line failing is "animation.Play();", that means there is no anim attached). If you select the object, then look at the "Animation" component in the inspector, you can assign the animation there. Often, the first step before you can do this is to split the anims on the model itself, which is done on the .fbx model itself, which you can select in the project pane. Then, with it selected, the FBX importer should become visible in the inspector panel. That's where you can name/split your anims.. If you give more info, it might help..
Thank you all so very much for answering my question. I haven't yet tried it out yet, but I'm certain your advice will work. I'll reply back again once I apply it.
Answer by syclamoth · May 02, 2012 at 01:00 AM
Presumably, this is happening because the AnimationState that you are retrieving (usually by accessing 'animation[string]') is invalid. Make sure that you're spelling the name of the animation properly, and that the animationClip in question is actually attached to the animation component in the inspector.
I still couldn't get it to work:( I've added the animation script up and down to the Red Target in the FBX Inspector. The 2 error messages that I receive is "The Animation State could not be Played, because it could not be found Please attach an animation clip with the name 'up' or call this function only for existing animations, and Please attach an animation clip with the name 'down' or call this function only for existing animations.
The animation may exist in the FBX importer, but that doesn't mean it's on the object in your scene! Look at the actual animation in your scene, and see if it has the correct animations attached. As previously stated, you need to make sure you spell the names properly.
For this kind of thing, I've gotten into the habit of identifying animations by public AnimationClip references assigned in the inspector- that way I can automatically add them to my animation components if it so happens that they've accidentally become disattached.