Performance: Controller/gamepad support
MEDIUM IMPACT
This affects input responsiveness and frame rendering smoothness when using controllers or gamepads.
void Update() {
float horizontal = Input.GetAxis("Horizontal");
float vertical = Input.GetAxis("Vertical");
bool jump = Input.GetButtonDown("Jump");
if (horizontal != 0 || vertical != 0) {
// Process movement
}
if (jump) {
// Process jump
}
}void Update() {
if (Input.GetAxis("Horizontal") != 0) {
// Process movement
}
if (Input.GetAxis("Vertical") != 0) {
// Process movement
}
if (Input.GetButtonDown("Jump")) {
// Process jump
}
}| Pattern | Input Queries per Frame | CPU Usage | Frame Drops | Verdict |
|---|---|---|---|---|
| Multiple separate Input.GetAxis/GetButtonDown calls | Many redundant calls | High | Possible frame drops | [X] Bad |
| Single batch input read stored in variables | Minimal calls | Low | Smooth frames | [OK] Good |