PlayerInput

Manages the player's input action schemes and cursor state. Tracks active InputActionScheme instances in a HashSet, enabling/disabling them as needed. Locks the cursor on enable and disables all schemes on disable.

Definition

Namespace: Paragon.Townskeep.PlayerSystem Assembly: Townskeep.dll

[AddComponentMenu("Input/Player Input")]
public class PlayerInput : ParagonBehaviour

Inheritance: SerializedMonoBehaviourParagonBehaviourPlayerInput

Remarks

PlayerInput is the player-side bridge to Paragon's InputActionScheme system. It maintains a set of currently active input schemes and provides methods to activate, disable, and query them.

Lifecycle

  1. Awake — Caches the Player reference and creates the activeSchemes set

  2. OnEnable — Locks the cursor and activates the default InputActionScheme on the same GameObject

  3. OnDisable — Disables all active schemes and clears the set

Input scheme management

Schemes are tracked in a HashSet<InputActionScheme> to prevent double-activation. ActivateInputScheme() only calls Enable() if the scheme was not already in the set; DisableInputScheme() only calls Disable() if the scheme was present and removed.

circle-info

The component is disabled by default. PlayerNetwork.Initialize() enables it only for the local client (networkPlayer.ClientID == ClientID), preventing remote player objects from processing input.

Quick Lookup

Goal
How

Access the player

playerInput.Player

Activate a scheme

playerInput.ActivateInputScheme(scheme)

Disable a scheme

playerInput.DisableInputScheme(scheme)

Disable all schemes

playerInput.DisableAllInputSchemes()

Find a scheme by name

playerInput.GetInputScheme("name")

Lock cursor

playerInput.LockCursor()

Unlock cursor

playerInput.UnlockCursor()

Properties

Player

The Player this input component belongs to.

Methods

Awake

Caches the Player component and creates the activeSchemes HashSet.

OnEnable (override)

Locks the cursor and activates the default InputActionScheme found on the same GameObject. Calls base.OnEnable() for debug system registration.

OnDisable (override)

Disables all active input schemes and clears the set. Calls base.OnDisable() for debug system unregistration.

LockCursor

Hides the cursor and locks it to the center of the screen.

UnlockCursor

Shows the cursor and unlocks it for free movement.

ActivateInputScheme

Enables an input scheme and adds it to the active set. No-op if the scheme is already active.

Parameter
Type
Description

inputScheme

InputActionScheme

The scheme to activate

DisableInputScheme

Disables an input scheme and removes it from the active set. No-op if the scheme is not active.

Parameter
Type
Description

inputScheme

InputActionScheme

The scheme to disable

DisableAllInputSchemes

Disables all currently active schemes and clears the active set.

GetInputScheme

Finds an active scheme by name. Returns null if not found.

Parameter
Type
Description

name

string

The scheme name to search for

Returns: The matching InputActionScheme or null.

Common Pitfalls

circle-exclamation
circle-exclamation
circle-exclamation

See Also

Last updated