Skip to content

API Class PlayerInput

github-actions[bot] edited this page Nov 24, 2026 · 5 revisions

Class: PlayerInput

Defined in: src/engine/input/facade.ts:60

One player's input, as a script reads it. From a behavior (this.input) it reads the pawn the behavior belongs to (the nearest node up its hierarchy with ControlledBy or an action set), so it also works on a server, where pawns get their connection's actions; from InputPlayers it reads the player's node.

Accessors

accessibility

Get Signature

get accessibility(): Readonly<InputAccessibility>;

Defined in: src/engine/input/facade.ts:187

The player's accessibility settings (changes apply next frame).

Returns

Readonly<InputAccessibility>

Set Signature

set accessibility(value): void;

Defined in: src/engine/input/facade.ts:191

Parameters
value

InputAccessibility

Returns

void


battery

Get Signature

get battery(): 
  | {
  charging: boolean;
  level: number;
}
  | null;

Defined in: src/engine/input/facade.ts:296

The battery of the player's gamepads: level 0..1 and whether it's charging (plugged in), for the paired gamepad with the lowest level when there are several. Null when none of them reports a level: no gamepad, a wired pad without a battery, or an adapter that can't tell (the browser's Gamepad API; desktop builds and WebHID pads in Chromium can).

Returns

| { charging: boolean; level: number; } | null


devices

Get Signature

get devices(): GameObject[];

Defined in: src/engine/input/facade.ts:229

The device nodes paired with this player.

Returns

GameObject[]


index

Get Signature

get index(): number;

Defined in: src/engine/input/facade.ts:72

The player's index, or -1 when no local player is behind it (a server pawn).

Returns

number


lastFamily

Get Signature

get lastFamily(): DeviceFamily;

Defined in: src/engine/input/facade.ts:159

The family of the device this player last performed an action with (prompts follow it).

Returns

DeviceFamily


player

Get Signature

get player(): GameObject | null;

Defined in: src/engine/input/facade.ts:77

The player's node (under the World's Input node), or null.

Returns

GameObject | null

Methods

canceled()

canceled(action): boolean;

Defined in: src/engine/input/facade.ts:136

Parameters

action

string

Returns

boolean


completed()

completed(action): boolean;

Defined in: src/engine/input/facade.ts:133

Parameters

action

string

Returns

boolean


elapsed()

elapsed(action): number;

Defined in: src/engine/input/facade.ts:107

Seconds the action has been actuated (hold progress, charge).

Parameters

action

string

Returns

number


held()

held(action): boolean;

Defined in: src/engine/input/facade.ts:112

Parameters

action

string

Returns

boolean


loadBindings()

loadBindings(profile?): Promise<boolean>;

Defined in: src/engine/input/facade.ts:220

Load what saveBindings saved (a format 1 file is upgraded); false if nothing was saved.

Parameters

profile?

string

Returns

Promise<boolean>


on()

on(
   action, 
   phase, 
   fn
): () => void;

Defined in: src/engine/input/facade.ts:147

Call fn when the action reaches phase, for this input's player or the node it reads: dispatched from ActionEvents, in the input phase for local players, and in the fixed step (before fixedUpdate scripts) for a pawn a network server writes a client's actions onto. From a behavior, it's unsubscribed when the behavior is disabled; the returned function unsubscribes sooner.

Parameters

action

string

phase

ActionEventPhase

fn

(e) => void

Returns

() => void


ongoing()

ongoing(action): boolean;

Defined in: src/engine/input/facade.ts:124

Parameters

action

string

Returns

boolean


pair()

pair(device): void;

Defined in: src/engine/input/facade.ts:235

Pair a device node with this player (taking it from any other).

Parameters

device

GameObject

Returns

void


performed()

performed(action): boolean;

Defined in: src/engine/input/facade.ts:130

Parameters

action

string

Returns

boolean


pressed()

pressed(action): boolean;

Defined in: src/engine/input/facade.ts:115

Parameters

action

string

Returns

boolean


prompt()

prompt(action, family?): InputPrompt | null;

Defined in: src/engine/input/facade.ts:164

What performs action, named for family (default: the family last used). Null if nothing does.

Parameters

action

string

family?

DeviceFamily

Returns

InputPrompt | null


rebind()

rebind(action, options?): Promise<RebindResult>;

Defined in: src/engine/input/facade.ts:173

Bind action to the player's next press (see RebindOptions): replace a control of its mapping for the device group, or with add: true add a mapping for it.

Parameters

action

string

options?

RebindOptions

Returns

Promise<RebindResult>


released()

released(action): boolean;

Defined in: src/engine/input/facade.ts:118

Parameters

action

string

Returns

boolean


resetBindings()

resetBindings(): void;

Defined in: src/engine/input/facade.ts:204

Drop every binding change: replaced controls, added mappings and removed ones (back to the contexts' bindings).

Returns

void


rumble()

rumble(
   low, 
   high, 
   durationMs
): void;

Defined in: src/engine/input/facade.ts:248

Rumble the player's gamepads: low and high motor strengths 0..1, for durationMs.

Parameters

low

number

high

number

durationMs

number

Returns

void


rumbleTriggers()

rumbleTriggers(
   left, 
   right, 
   durationMs
): void;

Defined in: src/engine/input/facade.ts:256

Rumble the triggers (DualSense and Xbox impulse triggers; where the device and platform can).

Parameters

left

number

right

number

durationMs

number

Returns

void


saveBindings()

saveBindings(profile?): Promise<void>;

Defined in: src/engine/input/facade.ts:212

Save the binding changes and accessibility with the game's settings, as input.<profile>.json (default player<index>), in profile format 2.

Parameters

profile?

string

Returns

Promise<void>


setLight()

setLight(
   r, 
   g, 
   b
): void;

Defined in: src/engine/input/facade.ts:275

Set the light bar colour (0..255 each; DualSense and DualShock 4, on desktop and through WebHID in Chromium).

Parameters

r

number

g

number

b

number

Returns

void


setSensors()

setSensors(enabled): void;

Defined in: src/engine/input/facade.ts:283

Turn gyro and accelerometer reports on or off (desktop, and WebHID in Chromium; off by default, they cost battery).

Parameters

enabled

boolean

Returns

void


setTriggerEffect()

setTriggerEffect(trigger, effect): void;

Defined in: src/engine/input/facade.ts:267

Set an adaptive trigger effect: resistance, a weapon's click, vibration (DualSense, on desktop and in Chromium browsers through WebHID). { mode: "off" } frees the trigger.

Parameters

trigger

"left" | "right"

effect

TriggerEffect

Returns

void


started()

started(action): boolean;

Defined in: src/engine/input/facade.ts:121

Parameters

action

string

Returns

boolean


triggered()

triggered(action): boolean;

Defined in: src/engine/input/facade.ts:127

Parameters

action

string

Returns

boolean


unbind()

unbind(action, options): boolean;

Defined in: src/engine/input/facade.ts:182

Remove the player's mapping of action for a device group (the first, by priority, unless context says which): one the player added is deleted, one of the context's own is recorded in the profile's removals (resetBindings brings it back). False when there was none.

Parameters

action

string

options

UnbindOptions

Returns

boolean


unpair()

unpair(device): void;

Defined in: src/engine/input/facade.ts:242

Unpair a device node from this player.

Parameters

device

GameObject

Returns

void


value()

value(action): number;

Defined in: src/engine/input/facade.ts:87

A button's or axis's value; a vector's length. 0 when there's nothing to read.

Parameters

action

string

Returns

number


vector2()

vector2(action, out?): Vector2;

Defined in: src/engine/input/facade.ts:95

A vec2 action's value (+Y up).

Parameters

action

string

out?

Vector2 = ...

Returns

Vector2


vector3()

vector3(action, out?): Vector3;

Defined in: src/engine/input/facade.ts:100

Parameters

action

string

out?

Vector3 = ...

Returns

Vector3

Clone this wiki locally