- Home /
Blender model animations not found after import
Hi everyone, I have a model that is the second I've create for my game. The first, I was able to import into unity with it's animations already attached with an animation component, but my second model imports without them. in addition, if I add the animation component in and drag the animations on to it, unity still can't find it in game. I get the following error;
The animation state Open could not be played because it couldn't be found!
Please attach an animation clip with the name 'Open' or call this function only for existing animations.
UnityEngine.Animation:Play(String)
Chest:Open() (at Assets/Scripts/Chest.cs:39)
Chest:OnMouseUp() (at Assets/Scripts/Chest.cs:31)
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32, Int32)
I'm not sure if this problem is due to unity or blender. this is how my animation work space appears prior to a save (I open my models in blender as .blends)
Update: I've since tried to export it as an .obj file, but the problem remains, so it can't be due to the .blend format
Here is the object in game
And here is the code that uses the animation;
using UnityEngine;
using System.Collections;
public class Chest : MonoBehaviour {
public enum State {
open,
close,
inbetween
}
public State _state;
// Use this for initialization
void Start () {
_state = Chest.State.close;
}
// Update is called once per frame
void Update () {
}
public void OnMouseEnter() {
Debug.Log("enter");
}
public void OnMouseExit() {
Debug.Log("exit");
}
public void OnMouseUp() {
Debug.Log("Up");
if (_state == Chest.State.close){
Open ();
}
else{
Close();
}
}
private void Open(){
animation.Play("Open");
_state = Chest.State.open;
}
private void Close(){
animation.Play("Close");
_state = Chest.State.close;
}
}
The .blend is fine, there is something wrong inside the Edtior, please post a screenshot of your model selected inside the editor. Also, .obj model have no animation, only mesh/uv data.
What are you import settings?
Don't forget, if you are using 4.x that the importer now has 3 tabs and you need to check the settings on all 3.
ScreenShots of those 3 windows would help.
@Paulo Henrique Thanks, I've included a screenshot of the object's property in the question.
@Little Angel do you mean import options on each animation? that's a good point, the first model was added when I was still using 3.x
Answer by Captain_Dando · Jan 30, 2013 at 12:59 PM
Ok, it turns out that if you have a project that transfers from version 3.x you might have to change the animations to "legacy" animations under import settings for the model's armature. After that, it should work perfectly.
Answer by Adam-Buckner · Jan 30, 2013 at 12:15 PM
Currently that animation component has no animation clip assigned, but 3 clips available.
Are you selecting the clip to play?
Animation Component in the docs
If you simply use Animation.Play() there is no default animation to play. If this is the case, you'd want to say: Animation.Play ("Open"); for example
If this isn't the answer you are looking for, can you post your code?
I've been using Animation.Play("Open") already :( I've included the code into my question
I forgot to mention, I added the animations manually to the animation component, I usually add the animation clip as idle, but didnt this time, nevertheless it doesn't really change it
Answer by Adam-Buckner · Jan 30, 2013 at 12:48 PM
FWIW: When I animated a chest lid, I set the default animation to Open, and then played Open to open the chest and played Open backwards to close it, so there was only one animation:
public void LootWindowToggle (bool toggle) { // A setter to set the lootPanelOpen to closed and stop TestDistance
lootPanelOpen = toggle;
PlayAnimation (toggle); // Is this the correct location?
}
protected void PlayAnimation (bool toggle) {
if (thisAnimation) {
if (toggle) {
foreach (AnimationState state in thisAnimation) {
if (state.normalizedTime < 0.0f)
state.normalizedTime = 0.0f;
state.speed = 1.0f;
}
} else {
foreach (AnimationState state in thisAnimation) {
if (state.normalizedTime > 1.0f)
state.normalizedTime = 1.0f;
state.speed = -1.0f;
}
}
thisAnimation.Play();
}
}
The one major advantage to this way of doing things is that you can reverse the animation while it is in progress
You can see this in action here.
The windows will get in the way in the current view so open a chest, then close the window on top. The you can start to close and reopen the lid and see that the animation simply reverses.
$$anonymous$$oreover, you can tie it into the state of the object, so you can click on the other chest and the first one will close.
I just fiddled around with the importer for a bit and it turns out that I had to change the animations to "legacy" under rigs. I'm going to post it as the reply, but thank you for all the help, you've given me a few new methods to work with, and you set me in the right direction to find the solution
Your answer
Follow this Question
Related Questions
Children won't animate 2 Answers
Blender to Unity - Child Of Bone Constraint With FPS Reload Animation 0 Answers
Importing assets 0 Answers
Animation Problems 1 Answer
Can Unity import un-rigged animations from blender? 0 Answers