Performance: Input action maps
MEDIUM IMPACT
Input action maps affect how quickly and efficiently user inputs are processed and responded to in the game, impacting input responsiveness and frame rate.
private InputAction jumpAction;
private InputAction interactAction;
void OnEnable() {
jumpAction.Enable();
interactAction.Enable();
jumpAction.performed += ctx => Jump();
interactAction.performed += ctx => Interact();
}
void OnDisable() {
jumpAction.Disable();
}void Update() {
if (Input.GetKeyDown(KeyCode.Space)) {
Jump();
}
if (Input.GetKeyDown(KeyCode.E)) {
Interact();
}
// Multiple if checks every frame
}| Pattern | Input Polling | CPU Usage | Input Lag | Verdict |
|---|---|---|---|---|
| Polling keys every frame | High (multiple checks) | High | Higher lag due to constant checks | [X] Bad |
| Using InputAction callbacks | Low (event-driven) | Low | Minimal lag, responsive input | [OK] Good |