Mecanim Drawer Animation problem?
I am trying to create a Dresser with drawers that when a key is taped open and when is taped again close, for this I used Mecanim, the animations runs properly but Mecanim passes trough my transitions all at once when I press the key once, it doesn't wait for me to tap the key again. My question is how can I make Mecanim after the first animation is played to wait until I tap the key again?
Here is my code:
public class Drawer : MonoBehaviour {
int state;
bool isClosed = false;
Animator anim;
// Use this for initialization
void Start () {
anim = GetComponent<Animator> ();
}
public void OnLookEnter ()
{
anim.SetInteger ("State", state);
if (Input.GetKeyDown (KeyCode.E)) { // Idle to open
state = 1;
}
if (Input.GetKeyDown (KeyCode.E) && state == 1) { //Open to close
state = 2;
}
if (Input.GetKeyDown (KeyCode.E) && state == 2) { // Close to open
state = 3;
}
}
// Update is called once per frame
void Update () {
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612035349im_/https://answers.unity.com/themes/thub/images/avi.jpg)