Skip to content

joystick

A virtual analog stick — the player drags a thumb-knob and the widget emits a normalized 2D vector. Best for movement, aim, or any continuous 2D input.

C# factory

using PairKit;
WidgetDefinitions.Joystick(
id: "stick",
positionX: 0.5f, positionY: 0.7f,
deadzone: 0.05f,
label: "Move"
);

Wire format

FieldTypeRequiredNotes
idstringyesStable identifier echoed in every event.
type"joystick"yes
position_x, position_ynumberno0..1 anchor on the screen.
deadzonenumberno0..1 fraction of the stick radius. Default 0.05.
labelstringnoCaption rendered above the stick.

Events

Event typePayloadFires when
move{ x: number, y: number }Player drags the knob. Values in [-1, 1]. Fires repeatedly while held.
release{ x: 0, y: 0 }Player lifts their finger.

evt.GetVector2() returns the (x, y) directly.

Example

manager.OnInput += (player, evt) =>
{
if (evt.WidgetId != "stick") return;
var dir = evt.GetVector2();
transform.position += new Vector3(dir.x, 0, dir.y) * Time.deltaTime * 5f;
};