InputActions

Static entry point for reading input actions from gameplay code, the action-level counterpart of Input. public override void OnUpdate(float deltaTime) { var move = InputActions.ReadVector("Move"); if (InputActions.WasPressed("Jump")) Jump(); }

Remarks

Resolves an InputActionService from RuntimeServices on each call, so a component works unchanged in the standalone runtime and in the Studio's play mode. With no service registered — or no asset loaded — every query returns a neutral value instead of throwing.

Example

` public override void OnUpdate(float deltaTime) { var move = InputActions.ReadVector("Move"); if (InputActions.WasPressed("Jump")) Jump(); } `

Properties

Service

(InputActionService?): The active action service, or null when actions are not routed.

Public Methods

Find

public static InputAction? Find(string path)

Finds an action by Map/Action or by a bare name.

Parameters:

  • path (string): The action to find.

Returns: InputAction?

  • The action, or null when nothing matches.

IsPressed

public static bool IsPressed(string path)

Whether an action is currently held.

Parameters:

  • path (string): The action to read.

Returns: bool

WasPressed

public static bool WasPressed(string path)

Whether an action went down during this frame.

Parameters:

  • path (string): The action to read.

Returns: bool

WasReleased

public static bool WasReleased(string path)

Whether an action went up during this frame.

Parameters:

  • path (string): The action to read.

Returns: bool

ReadAxis

public static float ReadAxis(string path)

An action's value as a single axis, −1 to 1.

Parameters:

  • path (string): The action to read.

Returns: float

ReadVector

public static Vector2 ReadVector(string path)

An action's value as a direction.

Parameters:

  • path (string): The action to read.

Returns: Vector2

SetMapEnabled

public static void SetMapEnabled(string name, bool enabled)

Enables or disables a whole map, so a menu can take input away from gameplay.

Parameters:

  • name (string): The map's name.
  • enabled (bool): Whether it should follow the devices.