Here’s a paranoid question. What exactly do GetButtonDown()
, GetButtonUp()
and GetButton()
return, and what is the relationship between them?
My own intuition tells me that GetButton()
should return the state of the button at the instant when the frame began, GetButtonDown()
should be equivalent to “GetButton() && !GetButton_FromPreviousFrame
” and GetButtonUp()
should be the same as “!GetButton() && GetButton_FromPreviousFrame
”. If so, then the following will always be true:
-
GetButtonDown()
always impliesGetButton()
, soGetButtonDown() && ~GetButton()
will always equal false. -
GetButtonUp()
always implies!GetButton()
, soGetButtonUp() && GetButton()
will always equal false. - From 1 and 2 it follows that
GetButtonDown() && GetButtonUp()
will always equal false.
Are these assumptions correct? Is this properly documented anywhere? My worst fear is that if in the duration of one frame the user magically manages to press a button and then release it, then both GetButtonDown()
and GetButtonUp()
will return true, and the same will happen if, on the contrary, the button is first released and then quickly pressed. Then I won’t be able to distinguish between these situations! And the fear is not purely hypothetical too: occasionally a long frame happens, that lasts for like 0.3 seconds, and it is physically possible to push a button and release it in that time.
UPDATE: ok, an update (apparently I cannot answer my own question). Assumptions 1 and 3 above are wrong, assumption 2 is in the gray area. The most important lesson is like this: GetButtonDown()
and GetButtonUp()
are not mutually exclusive and can both return true in the same frame.