Skip to content

InputManager

The InputManager maps player input to named actions. Your code asks “is jump held?” instead of “is the spacebar held?”, which lets you rebind devices and change input devices without touching gameplay code.

Open it from Inspector → Systems → InputManager → Open.

FieldWhat it does
presetStarting profile: platformer, topdown, fps, menu, or custom. Picks a sensible set of default actions.
actionsList of named actions; each has a type and a list of bindings.
deadzones.stickRadial deadzone for analog sticks (0..1). Default 0.2.
deadzones.triggerThreshold for analog triggers (0..1). Default 0.05.

Each action has a type that determines how its bindings are interpreted:

  • button: pressed/held/released. Bindings: any digital input (key, mouse button, gamepad button).
  • axis1d: scalar -1..1. Bindings: analog axes (left stick X, trigger), or pairs of keys (A/D as -1/+1).
  • axis2d: vector (x, y). Bindings: analog sticks, mouse delta, or four keys (WASD).
  • toggle: latched on/off. Each press flips state.

Each binding has a device (keyboard, mouse, gamepad, touch) and a code (the key name or button index). Multiple bindings per action are fine; pressing any of them triggers the action.

A typical platformer action map:

ActionTypeBindings
moveaxis1dkeyboard KeyA/KeyD, gamepad left-stick X
jumpbuttonkeyboard Space, gamepad button A
attackbuttonkeyboard KeyJ, mouse left, gamepad button X
interactbuttonkeyboard KeyE, gamepad button B
pausebuttonkeyboard Escape, gamepad Start

Picking a preset other than custom seeds the actions list with a sensible default. You can edit any preset’s actions after seeding; the preset choice doesn’t constrain you.

  • platformer: move (axis1d), jump, attack, interact, pause.
  • topdown: move (axis2d), interact, attack, inventory, pause.
  • fps: move (axis2d), look (axis2d, mouse), jump, primary, secondary, reload, pause.
  • menu: navigate (axis2d), confirm, back. Minimal.
  • custom: empty. Build the map from scratch.

The stick deadzone is radial: it ignores stick input below the threshold magnitude (not per-axis). This is the right shape for stick movement; per-axis deadzones cause stair-step diagonals that feel terrible.

Trigger deadzone is a flat threshold (analog triggers don’t have a center; they’re 0..1).

Defaults are 0.2 for sticks and 0.05 for triggers. These match what most console games use. Increase the stick deadzone for older / drifty controllers; decrease it for precision-twitch games.

Local multiplayer: define each action twice (p1_jump, p2_jump) with different bindings. The InputManager doesn’t track players explicitly; you partition by action name.

Rebinding UI: read the bindings list from gamemanager.toml at runtime; let the player edit; write back. The bundled SettingsManager’s controls category includes a rebinding scaffold.

Touch controls: bind touch device codes to on-screen virtual buttons. The bundles don’t ship touch controls but the system supports them.

[systems.InputManager.config]
preset = "platformer"
[systems.InputManager.config.deadzones]
stick = 0.2
trigger = 0.05
[[systems.InputManager.config.actions]]
name = "move"
type = "axis1d"
bindings = [
{ device = "keyboard", code = "KeyA-KeyD" },
{ device = "gamepad", code = "leftStickX" },
]
[[systems.InputManager.config.actions]]
name = "jump"
type = "button"
bindings = [
{ device = "keyboard", code = "Space" },
{ device = "gamepad", code = "A" },
]

Validation: action names are unique and match ^[a-z][a-z0-9_]*$. Deadzones must be 0..1.