InputAction

A named thing the game reacts to — Jump, Move, Look — with the controls that drive it. Gameplay code polls this or subscribes to it and never names a key, which is what makes a binding rebindable at runtime.

Remarks

A frame's value is the sum of every binding's contribution, clamped to the unit square for a vector or to −1..1 for an axis, so A and D held together cancel out the way a stick at rest does.

Properties

Name

(string) { get; set } = string.Empty: The action's name, unique inside its map.

Type

(InputActionType) { get; set } = InputActionType.Button: What shape of value the action produces.

Bindings

(List) { get; set } = []: The controls that drive it. Order is the order a rebinding addresses them by.

IsPressed

(bool): Whether the action is currently held.

WasPressed

(bool): Whether the action went down during this frame.

WasReleased

(bool): Whether the action went up during this frame.

Public Methods

ReadVector

public Vector2 ReadVector()

The action's value as a direction. Meaningful for every type; X alone for an axis.

Returns: Vector2

  • The current vector.

ReadAxis

public float ReadAxis()

The action's value as a single axis.

Returns: float

  • The current value, −1 to 1.

Update

public void Update(IInputSource source)

Recomputes the action from its bindings and raises whatever the change implies. Called once a frame by InputActionService, before the scene's update passes run.

Parameters:

  • source (IInputSource): The devices to read.

Reset

public void Reset()

Drops the action to rest without raising anything, for a map that was just disabled.