Skip to content

Latest commit

 

History

History
131 lines (77 loc) · 2.81 KB

File metadata and controls

131 lines (77 loc) · 2.81 KB
source

A customizable player input that is bound to an input action on a player's input device, such as a VR controller, gamepad, or on-screen button.

export declare class PlayerInput 

You can create a PlayerInput instance by calling the PlayerControls.connectLocalInput() method.
For more information about binding player input, see the Custom Input API guide.

The action this input is bound to. For analog inputs, a pressed state corresponds to an axis value greater than 0.5 or lesser than -0.5.

Signature

action: ReadableHorizonProperty<PlayerInputAction>;

Gets the axis value, between -1 and 1. If the input is digital, 0 or 1 is returned.

Signature

axisValue: ReadableHorizonProperty<number>;

Indicates whether the input is currently connected and active.

Signature

connected: ReadableHorizonProperty<boolean>;

Indicates whether the input is being held active. For analog inputs, a pressed state corresponds to an axis value greater than 0.5 or lesser than -0.5.

Signature

held: ReadableHorizonProperty<boolean>;

Indicates whether the input was pressed this frame.

Signature

pressed: ReadableHorizonProperty<boolean>;

Indicates whether the input was released this frame.

Signature

released: ReadableHorizonProperty<boolean>;

Disconnects the input. On platforms that display on-screen buttons for actions, the button will be removed. Any callbacks registered to this instance will stop being called.

Signature

disconnect(): void;

Returns

void

Registers a callback that is called when the input is pressed or released. For analog inputs, a pressed state corresponds to an axis value greater than 0.5 or lesser than -0.5.

Signature

registerCallback(callback: PlayerInputStateChangeCallback): void;

Parameters

callback: PlayerInputStateChangeCallback

The callback that is called when the pressed state changes.

Returns

void

Unregisters the currently registered callback, if any.

Signature

unregisterCallback(): void;

Returns

void