Animation doesn't play on Input


I’ve written a little script to open a door when the player is inside of a box collider and hits the Interact button (I’ve set it up to be ‘E’ in the input manager)(I’ve also tried this same code using the ‘E’ Keycode directly). It works (door opens) when I comment out the test for the interaction button (player just steps into the collider) but doesn’t seem to work when I add the extra if statement if (Input.GetButtonDown("Interact")).

Any idea what I could be doing wrong?


void OnTriggerEnter(Collider other) {

        if (other.tag == "Player")
        {
            canvas.enabled = true;
            if (Input.GetButtonDown("Interact"))
            {
                animator.SetBool("open", true);
            }
        }

Side note: Anyone else excited for Ludum Dare 40 tonight?!


Cheers!

Twitch answered my question on a stream (by the way, check out his stream, he’s an awesome guy and a fellow Unity developer! The Ludum Dare site links to his stream quite often!) and sorry if the devs don’t condone linking, but he did answer my question, for which I’m very grateful:

The problem was void OnTriggerEnter(Collider other) the compiler was looking for input only on the very first frame of entering the collider.
**
**
The solution was to change it to void OnTriggerStay(Collider other).