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
| Field | Type | Required | Notes |
|---|---|---|---|
id | string | yes | Stable identifier echoed in every event. |
type | "joystick" | yes | |
position_x, position_y | number | no | 0..1 anchor on the screen. |
deadzone | number | no | 0..1 fraction of the stick radius. Default 0.05. |
label | string | no | Caption rendered above the stick. |
Events
| Event type | Payload | Fires 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;};