Vixen
02b45cc4
csharp
public sealed class InputAction

One thing a player can do, and every way they can do it.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The unit the game codes against. A game asks Move.ReadValue<Vector2>() or listens for Performed; it never asks whether W is down, which is what makes rebinding, control schemes and device hot-swap possible at all.

Both APIs, and they are the same state. The event path drives UI, where a click has to be handled on the frame it happened; the polled path drives gameplay, where a simulation reads what is true now. Deriving one from the other — an event queue the gameplay code drains, or a poll the UI does — is where the two disagree by a frame.

One binding wins per frame for a Button or Value action: the one furthest from rest. Without that, a stick and WASD bound to the same action would sum to a magnitude of two when both are pushed, and a player who rests a hand on the pad while using the keyboard would drift.

Fields and properties (18)

  • public InputActionData Data

    What the asset said.

  • public string Name

    Its name, unique within its map.

  • public InputActionMap Map

    The map it belongs to.

  • public InputActionType Type

    What it does with its value.

  • public InputControlType ControlType

    The shape of its value.

  • public string Path

    Its full name, Player/Move.

  • public IReadOnlyList<InputBinding> Bindings

    Its bindings.

  • public bool IsEnabled

    Whether it is listening.

  • public InputActionPhase Phase

    Where it is in its lifecycle.

  • public Vector2 Value

    Its value, as of the last update.

  • public float Magnitude

    How far from rest it is.

  • public bool IsPressed

    Whether it is past its press point now.

  • public bool WasPressedThisFrame

    Whether it crossed the press point this frame.

  • public bool WasReleasedThisFrame

    Whether it fell below the press point this frame.

  • public bool WasPerformedThisFrame

    Whether an interaction was satisfied this frame.

  • public bool WasStartedThisFrame

    Whether an interaction began this frame.

  • public bool WasCanceledThisFrame

    Whether an interaction ended without being satisfied this frame.

  • public InputBinding? ActiveBinding

    The binding that produced the current value, or .

Events (3)

  • public Action<InputActionContext>? Started

    Raised when an interaction begins.

  • public Action<InputActionContext>? Performed

    Raised when an interaction is satisfied. The one most games listen to.

  • public Action<InputActionContext>? Canceled

    Raised when an interaction ends without being satisfied, or the control is released.

Methods (7)

  • public T ReadValue<T>() where T : struct

    Reads the value as the shape the caller expects.

  • public float ReadFloat()

    Reads the value as one axis.

  • public Vector2 ReadVector2()

    Reads the value as two axes.

  • public void CollectControls(List<InputControl> into)

    Every control this action currently reads.

  • public void OverrideBinding(int bindingIndex, string? path, int partIndex = -1)

    Replaces the path a binding reads.

  • public void RemoveBindingOverrides()

    Puts every binding back to what the asset says.

  • public override string ToString()

    Returns a string that represents the current object.

Used by (14)

  • MouseCaptureSystemThirdPersonShooter
  • PlayerRigThirdPersonShooter
  • ActionPlayerInputVixen.Engine
  • GeneratedAccessorTestsVixen.Input.Tests
  • InputActionContextVixen.Input
  • InputActionMapVixen.Input
  • InputActionTestsVixen.Input.Tests
  • InputActionsVixen.Input
  • InputBindingVixen.Input
  • InputBindingConflictVixen.Input
  • InputRebindingOperationVixen.Input
  • InputRebindingTestsVixen.Input.Tests
  • MenuActionsVixen.Input.Tests
  • PlayerActionsVixen.Input.Tests