Skip to content

API Class PlayerInput

github-actions[bot] edited this page Dec 1, 2026 · 5 revisions

Class: PlayerInput

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

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:188

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:192

Parameters
value

InputAccessibility

Returns

void


battery

Get Signature

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

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

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:246

The device nodes paired with this player.

Returns

GameObject[]


index

Get Signature

get index(): number;

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

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:160

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:78

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:137

Parameters

action

string

Returns

boolean


completed()

completed(action): boolean;

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

Parameters

action

string

Returns

boolean


elapsed()

elapsed(action): number;

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

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:113

Parameters

action

string

Returns

boolean


loadBindings()

loadBindings(profile?): Promise<boolean>;

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

Load what saveBindings saved (a format 1 file is upgraded); false if nothing was saved, or the file is from a newer Myco (refused with a warning, the bindings unchanged).

Parameters

profile?

string

Returns

Promise<boolean>


on()

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

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

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:125

Parameters

action

string

Returns

boolean


pair()

pair(device): void;

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

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:131

Parameters

action

string

Returns

boolean


pressed()

pressed(action): boolean;

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

Parameters

action

string

Returns

boolean


prompt()

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

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

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:174

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:119

Parameters

action

string

Returns

boolean


resetBindings()

resetBindings(action?): boolean;

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

Drop the player's binding changes: replaced controls, added mappings and removed ones (back to the contexts' bindings). With action (bare or "set.Id:action"), only that action's, in every context and for every device (ADR 0656). False when there was nothing to drop for the action.

Parameters

action?

string

Returns

boolean


rumble()

rumble(
   low, 
   high, 
   durationMs
): void;

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

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:273

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:224

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:292

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:300

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:284

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:122

Parameters

action

string

Returns

boolean


triggered()

triggered(action): boolean;

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

Parameters

action

string

Returns

boolean


unbind()

unbind(action, options): boolean;

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

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:259

Unpair a device node from this player.

Parameters

device

GameObject

Returns

void


value()

value(action): number;

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

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:96

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:101

Parameters

action

string

out?

Vector3 = ...

Returns

Vector3

Clone this wiki locally