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
Declaration
public ButtonControl down { get; set; }
Property Value
Type | Description |
---|---|
ButtonControl |
left
Declaration
public ButtonControl left { get; set; }
Property Value
Type | Description |
---|---|
ButtonControl |
right
Declaration
public ButtonControl right { get; set; }
Property Value
Type | Description |
---|---|
ButtonControl |
up
A synthetic button representing the upper half of the stick's Y axis.
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()