User Tools

Site Tools


en:tutorials:input:analog_stick_threshold

Analog Stick Threshold

In the SettingsTemplate, there is a property under Input called DefaultThreshold which looks like this:

[Input]
SetList         = MainInput
DefaultThreshold = 0.3
 
[MainInput]
JOY_LX_1 = LeftStickHorizontal

This property allows you to create a small dead zone in the centre of your controller sticks. What do I mean by this? Take a look at the following diagram:

The circle represents the entire area that a stick can be moved, from centre (0.0, 0.0), to the extreme edges which, if moved fully down, would be something like (0.0, 1.0). The values range from 0.0 to 1.0.

However, sticks are never perfectly at (0,0) when neutral. There is always some value being applied to the stick. Without a threshold, your object under control will never be stationary.

In the example image above, a threshold of 0.5 is applied. This means that half the area is dead (no values) in the centre, represented by the white circle.

Joystick values are only generated when the stick goes past the 0.5 threshold, which is represented by the blue area.

Values do not range between the threshold and 1.0, but rather, the 0.0 to 1.0 range is rescaled to fit the 0.5 to 1.0 range. This means that between threshold 0.5 and 1.0, the values returned are between 0.0 and 1.0

Of course, 0.5 is a very big threshold to place on a stick. If you don't supply the DefaultThreshold property, it will be 0.15 by default. And projects created using init ship as 0.3 as a default.

Hopefully, that's all clear and helpful. Enjoy working with controllers and sticks.

en/tutorials/input/analog_stick_threshold.txt · Last modified: 2020/08/31 05:37 (4 years ago) by sausage