Fix dead zone "stick creep"
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## Problem
As of at least Bevy v0.18.1 the current implementation for handling game-pad axis dead zones does not behave as expected and leads to stick creep in the absence of any input.
## Description
Currently the system implements dead zones by taking the raw input values, clamping them to the functional range, comparing that new value to the old value (similarly clamped to the functional range), and then only updating the value if the difference is above the significance threshold. In the case when a stick is used then released and allowed to center itself, the last raw value that passes the filter will be just barely outside the dead zone, but future raw values that are within the dead zone, which would otherwise create a significant difference, will instead be clamped to exactly the dead zone threshold, and thus will not pass the filter because the difference isn't significant enough. As a result, the value will never actually reach the dead zone threshold, and when scaled will never reach zero. Because of this, anyone that read the axis state from the game-pad must either check the value against a redundant significance threshold before using, or accept that the stick will slowly creep when not in use.
## Solution
The fundamental issue with this approach is that it clamps and then compares differences instead of comparing differences and then clamping. To produce the intended behavior, the system should first use the unclamped values to filter only significant differences, and then clamp the values when updating them.
## Similar Issues
This issue is related to, and a partial duplicate of #3691. However, the other issue focused on a more significant rewrite of the dead zone configurations to allow for additional options. While those changes seem like positive ones, they also seem like they may take a while and may be a fairly low priority (considering the issue was opened over four years ago now). In the short term, it would be nice if the current system was simply fixed so that it at least operates as expected, and doing so seems like it would be fairly trivial.
Contributor guide
Assessment
This issue has not been assessed yet.