I have found out that I can’t use inputs inside the OnTriggerEnter. I have to use input stuff inside Update. but, I need OnTriggerEnter to do several things. I have searched and really found nothing that resembled my problem to that degree, except I did find, that I should probably use OnTriggerStay instead. What I am trying to do is open a door that determines first if the door is locked(which is a bool) and Input.GetkeyDown(Keycode.E). if both of those are true then it plays the open door animation.
Any advise?
The easiest solution is to use a a bool member variable. Set it to true on OnTriggerEnter and false in OnTriggerExit. Check that bool and Input.GetKeyDown in your Update function. Note that if you want to support multiple players, you’ll need something more sophisticated than a bool, but it’ll be the same basic idea.
Yes , you can do a 2 boolean check. Like if the door has a boolean value to determined if it is closed or open.
if ( Input.GetKeyDown(Keycode.E) )
{
if ( DoorIsHit && DoorIsClose )
{
OpenTheDoor();
}
}