- Home /
 
 
               Question by 
               knightmar · May 04, 2019 at 05:10 AM · 
                triggernot workingontriggerstaygetbuttondownontrigger  
              
 
              OnTriggerStay simple question
I have GetKeyDown under OnTriggerStay but sometimes I need to click few times until it'll finally work. Why is that happening?
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by galactichyperstar · May 04, 2019 at 05:14 AM
Because OnTriggerStay triggers during the physics update. So, you press the key on frame 1, but physics update is not called on that frame. Next frame, you still have the key pressed, but GetKeyDown is only true if the key was press this frame, so if the physics update happens now, it wont trigger the GetKeyDown. You can change GetKeyDown to GetKey, or when you GetKeyDown, change a bool to true, and then once the OnTriggerStay happens, set it back to false.
Your answer