- Home /
Character spins constantly when using legacy animation, game claims animation does not exist.
I created a model with an animation in Blender, exported as an fbx, and imported into Unity. The animation is actually a series of animations that were strung together in Blender for convenience, so when importing the fbx, I split the animation into 10 animations. I also set the animation as Legacy, because Unity told me to.
Then, I added an animation component to my object, and set all the animations as elements under the Animations tab.
Lastly, I modified the player's movement script so that if no buttons were pressed, the code "GetComponent ().Play ("Normal");" would play.
However, when I try to run my game, two things happen: the message "The animation state Normal could not be played because it couldn't be found! Please attach an animation clip with the name 'Normal' or call this function only for existing animations." would show up in the console any time the line of code was called, and the player would spin around uncontrollably.
It can't be anything in the movement code, because it works fine if uncheck the animation component. The animation shouldn't be affecting the physics anyway, as the object has a box collider and I have "Animate Physics" unchecked.
So what's going on?
If I explained my problem poorly, I can upload a unity file for anyone who wants to see.
If you run that line of code whenever the player is not pressing any key then you're running that line on multiple consecutive frames, is that what you want? Should you play the animation when nothing is being pressed AND any of the movement keys was released in the current frame?
Also, I'd use an animator ins$$anonymous$$d of the animation component, setting the "Legacy" when importing the FBX doesn't prevent you from using an animator.
Anyway, I'm not sure why would your character spin, so... can you share the Unity file? I'd like to see it.
@DiegoSLTS Here's the unity file: http://www.mediafire.com/download/x42378we8chnrja/AnimationTest.zip
Yes, the code is run on multiple consecutive frames, but I'm planning on getting all my conditions in order once I've sorted this out. For example, an easy condition would be to not play the animation if it's already playing, but seeing as the animation apparently doesn't exist, I figured I'd wait until I figured out what was going on.
I tried creating an animator, but it wouldn't let me add the animations- unless I was doing it wrong? The manual isn't very clear.
Thanks for all your help.
Answer by DiegoSLTS · Aug 30, 2015 at 11:58 PM
I think I found the main problem. Look in the hierarchy, go to goku -> Armature -> Bone.021, there's another "goku" GameObject as a child with a RigidBody, BoxCollider, Animation and MovementScript components. It looks like you made a copy of it by mistake or something like that. Removing or deactivating that GameObject will stop that weird rotation.
It looks I was wrong about using the animator when importing the FBX rig as Legacy. I couldn't do it either, I've done that in other projects but I think I used .blend files, not FBX.
Your answer
Follow this Question
Related Questions
UNET NetworkAnimator Compatible with Legacy? 0 Answers
Why I can't play animations in my 2D game? 0 Answers
Legacy Animation doesn't work... 1 Answer
How to play animation (C#) 3 Answers