User Tools

Site Tools


en:tutorials:analog_stick_threshold

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

en:tutorials:analog_stick_threshold [2018/09/22 14:55 (12 months ago)] (current)
sausage created
Line 1: Line 1:
 +====== Analog Stick Threshold ======
  
 +In the [[https://​github.com/​orx/​orx/​blob/​master/​code/​bin/​SettingsTemplate.ini#​L175|SettingsTemplate]],​ there is a property under ''​Input''​ called ''​DefaultThreshold''​ which looks like this:
 +
 +<code ini>
 +[Input]
 +SetList ​        = MainInput
 +DefaultThreshold = 0.3
 +
 +[MainInput]
 +JOY_LX_1 = LeftStickHorizontal
 +</​code>​
 +
 +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:
 +
 +{{ :​examples:​stick-threshold.png |}}
 +
 +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 [[en:​tutorials:​creating_your_own_project|init]] ship as 0.3 as a default.
 +
 +Hopefully, that's all clear and helpful. Enjoy working with controllers and sticks. ​
en/tutorials/analog_stick_threshold.txt ยท Last modified: 2018/09/22 14:55 (12 months ago) by sausage