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;
}
}