Game Development Reference
In-Depth Information
Figure 5.2 Joystick dead zone causes input within the inner circle to be ignored.
A very basic dead zone implementation would be to set the x and y values to zero
in cases where they are relatively close to zero. If the values range between +/-
32K, perhaps a ~10% dead zone of 3,000 could be utilized:
Click here to view code image
int deadZone = 3000
Vector2 joy = get joystick input
if joy . x >= - deadZone && joy . x <= deadZone
joy . x = 0
end
if joy . y >= - deadZone && joy . y <= deadZone
joy . y = 0
end
However, there are two problems with this approach. First of all, the dead zone
will be a square instead of a circle. This means if you press the joystick such that
Search WWH ::




Custom Search