Thursday, June 11, 2020

Input use cases

There are 4 basic input use cases. A key is down, a key is up, a key that was up the previous frame is now down and a key that was down the previous frame is now up. The same is true for mouse buttons. Analog inputs have more use cases such as how far in a direction it is pressed.

The most common use case for a key being down is movement in a direction. If the key is down the object moves in a direction. Another reason could be a shield or some other state.

A key being up is less common. I would use it for charging something. For example, if space caused a shield to be up while pressed and it recharged while it is up you'd want to test for that.

A key that was up and is now down is most common for instant actions that need to happen immediately. The most common is firing a weapon.

A key that was down and now up is often used in UI. I use it in menus and activating objects. In theory it prevents bleed through between frames.

No comments:

Post a Comment