Play fbx animation on trigger and keypress
Hi - apologies for asking here - but I've got a headache trying to get my imported fbx animation to play on trigger and a keypress. I can get it to run with the keypress fine, with the following c#: private Animator shutterOpen; void Start() { shutterOpen = GetComponent(); } void Update () { if (Input.GetButtonDown("Open")) { shutterOpen.Play("Open"); } I then modified the script to add guiPanel on collision with box collider (set to Is Trigger), as follows: public GameObject guiObject; public Animator shutterOpen;
// Use this for initialization
void Start()
{
guiObject.SetActive(false);
shutterOpen = GetComponent<Animator>();
}
// Update is called once per frame
void OnTriggerStay(Collider other)
{
if (other.gameObject.tag == "Player")
{
guiObject.SetActive(true);
if (guiObject.activeInHierarchy == true && Input.GetButtonDown("Use"))
{
shutterOpen.Play("Open");
}
}
}
void OnTriggerExit()
{
guiObject.SetActive(false);
My imported fbx animation clip is called "Open". I've setup the Input Manager for "Use" and that works OK - but I cannot get the animation to play with both the trigger and keypress. Any help would be much appreciated. Thanks in advance.
Your answer
Follow this Question
Related Questions
Selecting animation to play based on boolean 1 Answer
ANIMATION TRIGGER DOESN'T PLAY 1 Answer
How do I check if the x position of my object is 0? 1 Answer
OnTriggerEnter2D not working 2 Answers
Trigger Collider is Triggering? 0 Answers