Class StickControl
A two-axis thumbstick control that can act as both a vector and a four-way dpad.
Inherited Members
Namespace: UnityEngine.InputSystem.Controls
Syntax
public class StickControl : Vector2Control
Remarks
Stick controls are used to represent the thumbsticks on gamepads (see leftStick and rightStick) as well as the main stick control of joysticks (see stick).
Essentially, a stick is an extended Vector2
control that can function either
as a combined 2D vector, as independent vertical and horizontal axes, or as four
individual, directional buttons. The following example demonstrates this based on the
gamepad's left stick.
// Read stick as a combined 2D vector.
Gamepad.current.leftStick.ReadValue();
// Read X and Y axis of stick individually.
Gamepad.current.leftStick.x.ReadValue();
Gamepad.current.leftStick.y.ReadValue();
// Read the stick as four individual directional buttons.
Gamepad.current.leftStick.up.ReadValue();
Gamepad.current.leftStick.down.ReadValue();
Gamepad.current.leftStick.left.ReadValue();
Gamepad.current.leftStick.right.ReadValue();
In terms of memory, a stick controls is still just from one value for the X axis and one value for the Y axis.
Unlike dpads (see DpadControl), sticks will usually have deadzone processors (see StickDeadzoneProcessor) applied to them to get rid of noise around the resting point of the stick. The X and Y axis also have deadzones applied to them by default (AxisDeadzoneProcessor). Note, however, that the deadzoning of individual axes is different from the deadzoning applied to the stick as a whole and thus does not have to result in exactly the same values. Deadzoning of individual axes is linear (i.e. the result is simply clamped and normalized back into [0..1] range) whereas the deadzoning of sticks is radial (i.e. the length of the vector is taken into account which means that both the X and Y axis contribute).
Properties
down
A synthetic button representing the lower half of the stick's Y axis, i.e. the -1 to 0 range (inverted).
Declaration
public ButtonControl down { get; set; }
Property Value
Type | Description |
---|---|
ButtonControl | Control representing the stick's lower half Y axis. |
Remarks
The control is marked as synthetic.
left
A synthetic button representing the left half of the stick's X axis, i.e. the -1 to 0 range (inverted).
Declaration
public ButtonControl left { get; set; }
Property Value
Type | Description |
---|---|
ButtonControl | Control representing the stick's left half X axis. |
Remarks
The control is marked as synthetic.
right
A synthetic button representing the right half of the stick's X axis, i.e. the 0 to 1 range.
Declaration
public ButtonControl right { get; set; }
Property Value
Type | Description |
---|---|
ButtonControl | Control representing the stick's right half X axis. |
Remarks
The control is marked as synthetic.
up
A synthetic button representing the upper half of the stick's Y axis, i.e. the 0 to 1 range.
Declaration
public ButtonControl up { get; set; }
Property Value
Type | Description |
---|---|
ButtonControl | Control representing the stick's upper half Y axis. |
Remarks
The control is marked as synthetic.
Methods
FinishSetup()
Declaration
protected override void FinishSetup()