- Home /
Input seemingly not working with trigger
For some reason when I tried to add an input to a trigger area as to activate a door animation, for some reason that does not work.
However when I check and unchecked the state of the door animation that does work. There's a boolean variable called "DoorState" that controls the door animation in the script.
I first tried to use the input script within the collision detect area however that did not seem to work, so I moved it to the function update area with a variable called "PlayerCollision" that is only set to true when the player walks into the trigger area / false when not.
I am also new to the question area, sorry if there is incorrect formatting.
Should also say that it is javascript
here is the code :
Have you checked if your "isopen" is in the same case with the bool in your animator controller?
Answer by jchester07 · Nov 25, 2017 at 07:30 AM
Found it. You might have problem in your Update function when you press the input button. As your code would always return to false. From line 30 to 36
Try doing it this way.
if (DoorState == false) { // A little more simple way would be: if(!DoorState)
DoorState = true;
} else {
DoorState = false;
}
Thanks, for the help, the code works as I wanted it to be, thank you.
Your answer
![](https://koobas.hobune.stream/wayback/20220612143316im_/https://answers.unity.com/themes/thub/images/avi.jpg)