01 — Input System Concepts
The problem with the old way
The classic Input Manager looks friendly at first:
if (Input.GetKeyDown(KeyCode.Space)) Jump();
But that line hard-wires Space. Add gamepad support and you're writing if (space OR joystick button 0). Add rebindable controls, touch, a pause menu that ignores gameplay keys... it collapses into spaghetti. Every serious project outgrows it.
The big idea: actions, not keys
The Input System flips the question from "which key is down?" to "did the player Jump?". Your code only ever talks about verbs; a data asset decides which physical controls trigger them.
Device control ──binding──▶ Action ──event/value──▶ Your C#
<Keyboard>/space ─────┐
<Gamepad>/buttonSouth ┴────▶ "Jump" ──performed──▶ OnJump()
The vocabulary (memorize these five)
- Action — a named thing the player can do:
Jump,Move,Fire. Has a type:- Button — fires events when pressed/released (
Jump,Fire) - Value — continuously supplies data (
Move→ Vector2,Point→ position)
- Button — fires events when pressed/released (
- Binding — a path from a device control to an action:
<Gamepad>/leftStick → Move. One action usually has several. - Composite binding — several controls pretending to be one: W/A/S/D combined into a single Vector2 ("2D Vector composite").
- Action Map — a group of actions that are on together:
Player2D,Player3D,Puzzle,UI. Enable the map you need; disable the rest. (This is how a pause menu ignores gameplay input — see 08 - Going Further.) - Control Scheme — a labeled set of devices (
Keyboard&Mouse,Gamepad) used for device switching and local multiplayer.
All of these live together in one Input Actions asset (.inputactions file) — the kit's is torn apart in 03 - The Input Actions Asset.
Events vs polling — the two ways C# consumes actions
// POLLING — ask every frame (great for continuous Values)
Vector2 move = moveAction.ReadValue<Vector2>();
// EVENTS — be told when something happens (great for Buttons)
jumpAction.performed += OnJump;
Button actions raise three events, in order: started (control touched), performed (it counts — pressed past the threshold), canceled (released). The platformer demo uses canceled for variable jump height; the puzzle demo uses started/canceled as press/release for dragging. Details in 04 - Reading Input in C Sharp.
Why this pays off for each game type in this kit
- The platformer binds WASD, arrows, d-pad, and stick to one
Moveaction — four input styles, one line of code. - The FPS binds mouse delta and right stick to
Look— same action, and the code only branches for sensitivity. - The puzzle binds mouse, pen, and touch to one
Pointaction — drag-and-drop works on a phone without changes.