Hello UA,
I am making a very simple script to animate a door opening and closing on proximity by pressing e. What happens though, is I can spam e and the animations don’t finish. How can I make the script wait before you can press e to start the animation until the other animation finishes? I am still new to Unity, so try to explain why you do certain things vs others. FYI, the door is on the back of a ship and flips down. Finally, ask for clarification if needed.
CODE:
using UnityEngine;
using System.Collections;
public class OpenShipDoor : MonoBehaviour {
bool doorup = false;
void OnTriggerStay(Collider other){
if (Input.GetKeyDown ("e"))
{
if (doorup == false)
{
doorup = true;
animation.Play("doorup1");
}
else
{
doorup = false;
animation.Play("doordown1");
}
}
}
}