Skip to content

t1k:unity:base:input-system

FieldValue
Modulebase
Version2.2.2
Efforthigh
Tools

Keywords: controls, input, input system, unity

/t1k:unity:base:input-system

New Input System for Unity 6 (com.unity.inputsystem 1.15+). Replaces legacy Input.GetKey/GetAxis.

  1. Install com.unity.inputsystem via Package Manager
  2. Project Settings → Player → Active Input Handling → “Input System Package” (or “Both”)
  3. Assets → Create → Input Actions — creates .inputactions asset
  4. On asset Inspector: enable Generate C# Class → get a typed wrapper
private GameInputActions _input;
void Awake() => _input = new GameInputActions();
void OnEnable() { _input.Player.Enable(); _input.Player.Fire.performed += OnFire; }
void OnDisable() { _input.Player.Fire.performed -= OnFire; _input.Player.Disable(); }
void Update() {
Vector2 move = _input.Player.Move.ReadValue<Vector2>(); // continuous
}
void OnFire(InputAction.CallbackContext ctx) => Shoot(); // event-driven
TypeUseReadValue
ButtonPress/releasefloat (0 or 1)
ValueContinuousfloat, Vector2, Vector3
PassThroughRaw, no conflict resolutionSame as Value
started → input begins (key down, stick leaves center)
performed → input completes (button press, hold threshold met)
canceled → input ends (key up, stick returns to center)

Use performed for buttons; read Value actions in Update().

Attach to GameObject → assign .inputactions asset → pick Behavior:

BehaviorHow
Send MessagesOnMove(InputValue) called on same GameObject
Invoke Unity EventsWire in Inspector
Invoke C# EventsplayerInput.onActionTriggered

Local multiplayer: PlayerInputManager (auto-spawns per player, split-screen).

Input is managed — cannot read inside Burst. Pattern: SystemBase reads → singleton → Burst ISystem consumes.

// 1. Singleton component (unmanaged)
public struct PlayerInputData : IComponentData {
public float2 Move;
public bool FireThisFrame;
}
// 2. Managed reader (NOT Burst) — InitializationSystemGroup
[UpdateInGroup(typeof(InitializationSystemGroup))]
public partial class InputReaderSystem : SystemBase {
private GameInputActions _input;
protected override void OnCreate() {
_input = new GameInputActions();
_input.Player.Enable();
EntityManager.CreateSingleton<PlayerInputData>();
}
protected override void OnUpdate() {
SystemAPI.SetSingleton(new PlayerInputData {
Move = (float2)_input.Player.Move.ReadValue<Vector2>(),
FireThisFrame = _input.Player.Fire.WasPressedThisFrame(),
});
}
protected override void OnDestroy() => _input.Dispose();
}
// 3. Burst ISystem reads singleton
[BurstCompile]
public partial struct MoveSystem : ISystem {
public void OnUpdate(ref SystemState state) {
var input = SystemAPI.GetSingleton<PlayerInputData>();
// use input.Move, input.FireThisFrame
}
}

→ See references/dots-input-basics.md for singleton bridge, fixed timestep buffering, FixedInputEvent, lifecycle patterns. → See references/dots-input-advanced.md for action map switching, Netcode IInputComponentData, MonoBehaviour bridge, anti-patterns.

  1. Enable action maps — actions don’t fire until Enable() is called
  2. Button phase — use performed, not started, for single press
  3. InputValue lifetime — only valid inside callback; don’t cache
  4. ISystem + Burst — never call Input System inside [BurstCompile]; use singleton bridge
  5. “Both” input mode — can cause duplicate events if old Input code remains
  6. UI stops working — replace StandaloneInputModule with InputSystemUIInputModule
  7. Rebinding UI — use WithSuppressedActionPropagation() (1.15+) to prevent actions firing during rebind
  8. OnScreenStick deadzone — virtual sticks have no built-in deadzone; add stickDeadzone processor
  9. WasPressedThisFrame lost in FixedStep — true for only ONE variable frame; use FixedInputEvent for fixed-rate systems
  10. InputActions.Dispose() mandatory — generated class is IDisposable; missing it leaks native memory
  11. Netcode: no polling in PredictedSimulationSystemGroup — re-runs on rollback; use IInputComponentData only
FileContent
references/bindings-processors-interactions.mdProcessors, interactions, composites, rebinding, gamepad rumble
references/ui-debugging-onscreen.mdInputSystemUIInputModule, Input Debugger, OnScreenButton/Stick
references/dots-input-basics.mdSingleton bridge, fixed timestep buffering, FixedInputEvent, lifecycle
references/dots-input-advanced.mdAction map switching, Netcode IInputComponentData, anti-patterns
references/device-management-testing.mdDevice lifecycle, InputTestFixture, custom devices