The Input System
Unity 6 projects use the Input System package (com.unity.inputsystem). Instead of asking "is the W key down?", you define actions ("Move", "Jump", "Interact") and bind them to controls on any device: keyboard, mouse, gamepad, touch, XR. Gameplay code reads the action and doesn't care which device produced it.
Migrating: The old Input Manager (
Input.GetAxis("Horizontal"),Input.GetKeyDown(KeyCode.Space), Project Settings > Input Manager) is legacy. New projects from the Unity 6 templates have the Input System installed and Active Input Handling (Project Settings > Player > Other Settings) set to use it. Old code throwsInvalidOperationExceptionwhen only the new system is active.
Concepts
| Term | Meaning |
|---|---|
Action asset (.inputactions) |
a file holding action maps, actions and bindings, edited in a dedicated window |
| Action map | a group of actions active together: Player, UI, Vehicle |
| Action | one logical input with a type: Value (a stick, Vector2), Button (pressed/released) or Pass-Through |
| Binding | a control path such as <Keyboard>/space or <Gamepad>/leftStick; composites combine keys into a value (WASD → Vector2) |
| Interaction / processor | when it triggers (Hold, Tap, MultiTap) and how the value is transformed (deadzone, invert, normalize) |
| Control scheme | a named set of devices ("Keyboard&Mouse", "Gamepad") used for auto-switching and local multiplayer |
Unity 6 adds project-wide actions: an asset named InputSystem_Actions assigned in Project Settings > Input System Package, created by the templates with default actions such as Move, Look, Jump, Attack and Interact. Code reaches it through InputSystem.actions without needing a reference.
Reading actions
There are three common styles. Use one per project.
1. Polling in Update (simple, great for movement):
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerInputReader : MonoBehaviour
{
InputAction move, jump;
void Awake()
{
move = InputSystem.actions.FindAction("Move"); // cache: FindAction is a lookup
jump = InputSystem.actions.FindAction("Jump");
}
void Update()
{
Vector2 stick = move.ReadValue<Vector2>(); // WASD, arrows or left stick
if (jump.WasPressedThisFrame()) Debug.Log("jump"); // true for exactly one frame
if (jump.IsPressed()) { /* held */ }
}
}2. Callbacks (good for discrete events; subscribe in OnEnable, unsubscribe in OnDisable):
[SerializeField] InputActionReference interact; // drag an action from the asset in the Inspector
void OnEnable()
{
interact.action.performed += OnInteract;
interact.action.Enable(); // actions outside the project-wide asset must be enabled
}
void OnDisable() => interact.action.performed -= OnInteract;
void OnInteract(InputAction.CallbackContext ctx) => Debug.Log(quot;interact from {ctx.control.device.displayName}");3. The PlayerInput component: add it to the player, assign the actions asset, and choose a Behavior (Send Messages, Broadcast Messages, Invoke Unity Events, Invoke C# Events). With Send Messages it calls methods named OnMove(InputValue value), OnJump() on the same GameObject. It also handles device assignment and control-scheme switching, and PlayerInputManager builds local multiplayer from it (one PlayerInput per joining device).
Callbacks fire in three phases: started (the control left its default state), performed (the interaction completed: pressed, or held long enough for Hold) and canceled.
Why input is read in Update
Presses are short. If you check WasPressedThisFrame() in FixedUpdate, a press can begin and end between two physics steps and be missed. The usual pattern is: read in Update, store an intent, consume it in FixedUpdate. The model compares both, using the frame timing from the lifecycle lesson:
using System;
// Unity's input state updates once per rendered frame, before Update. FixedUpdate runs
// earlier in the frame, so it sees the flag set during the previous frame.
(int naive, int buffered) Run(int[] frameMs, int pressFrame)
{
const int FixedMs = 20;
int acc = 0, naive = 0, buffered = 0;
bool buffer = false;
for (int f = 0; f < frameMs.Length; f++)
{
acc += frameMs[f];
while (acc >= FixedMs) // FixedUpdate steps of this frame
{
acc -= FixedMs;
if (pressFrame == f - 1) naive++; // WRONG: polling WasPressedThisFrame in FixedUpdate
if (buffer) { buffered++; buffer = false; } // RIGHT: consume the jump buffered in Update
}
if (f == pressFrame) buffer = true; // Update: WasPressedThisFrame() is true
}
return (naive, buffered);
}
int[] fps60 = { 16, 16, 16, 16, 16, 16, 16, 16 };
int[] fps30 = { 33, 33, 33, 33, 33, 33, 33, 33 };
for (int press = 2; press <= 5; press++)
{
var (n60, b60) = Run(fps60, press);
var (n30, b30) = Run(fps30, press);
Console.WriteLine(quot;press in frame {press}: 60 FPS naive={n60} buffered={b60} | 30 FPS naive={n30} buffered={b30}");
}press in frame 2: 60 FPS naive=1 buffered=1 | 30 FPS naive=2 buffered=1
press in frame 3: 60 FPS naive=1 buffered=1 | 30 FPS naive=2 buffered=1
press in frame 4: 60 FPS naive=0 buffered=1 | 30 FPS naive=1 buffered=1
press in frame 5: 60 FPS naive=1 buffered=1 | 30 FPS naive=2 buffered=1
Polling a one-frame flag in FixedUpdate jumps zero, one or two times for the same tap, depending on how many physics steps the next frame happens to run. Buffering in Update and consuming in FixedUpdate jumps exactly once, at any frame rate.
Test yourself
Which action type fits a movement stick or WASD?
- Button
- Value (Vector2)
- Pass-Through bool
- Hold interaction
How do you reach the project-wide Jump action from code in Unity 6?
Input.GetButton("Jump")InputSystem.actions.FindAction("Jump")Keyboard.JumpPlayerPrefs.GetAction("Jump")
Why read button presses in Update and consume them in FixedUpdate?
- FixedUpdate can't access input
- A short press can fall between physics steps and be missed
- Update is faster
- The Input System only updates in LateUpdate