๐บ๏ธ Lesson 3.2: Input Actions & Action Maps
Now that the package is installed, we need a place to define your game's controls. That place is the .inputactions asset โ a visual editor where you group Actions into Action Maps and bind physical controls to them. In this lesson you'll build a "Player" map with a Move action (driven by a WASD composite) and a Jump action.
๐ฏ Learning Objectives
By the end of this lesson, you will be able to:
- Create an .inputactions asset and open the Input Actions editor
- Explain what an Action Map is and why you'd have more than one
- Choose the right Action Type (Value, Button, Pass-Through) and Control Type (Vector2, Button)
- Add bindings, including a 2D Vector composite for WASD movement
- Build a Player map with
Move(Vector2) andJump(Button)
Estimated Time: 45 minutes ยท Prerequisite: Lesson 3.1 (Input System installed, Active Input Handling set)
In This Lesson
The .inputactions Asset
Your controls don't live in code โ they live in a dedicated asset. To create one, right-click in the Project window and choose Create โธ Input Actions. Name it something clear like PlayerControls. Unity writes a PlayerControls.inputactions file (it's JSON under the hood) and double-clicking it opens the visual Input Actions editor.
๐ Definition
.inputactions asset: a single file describing all your game's Action Maps, Actions, and Bindings as data. Because it's data, you can rebind it at runtime, share it across scenes, and generate a C# class from it โ all things you'll do later in this module.
Think of the asset as a three-level tree:
- Action Maps โ the top level. Each map is a set of controls for one context (Player, UI, Driving).
- Actions โ inside a map. Each is one intent (Move, Jump, Fire).
- Bindings โ inside an action. Each ties a physical control (a key, a stick, a button) to the action.
Reading the Input Actions Editor
The editor is a three-column window. On the left are your Action Maps; the middle lists the Actions (and their bindings) in the selected map; the right shows the Properties of whatever you've selected. Here's the exact layout we're about to build โ a Player map with a Move action (expanded to show its 2D Vector composite) and a Jump action:
๐ก Why a diagram and not a screenshot? Like the Animator, the Input Actions editor is drawn with a technology that doesn't screenshot cleanly, so it's rebuilt here as a precise diagram from the real asset. Every column, action, and binding matches what you'll see on screen.
Action Maps: Grouping by Context
An Action Map is a named group of actions that belong together and are usually active at the same time. The classic split is:
- Player โ Move, Jump, Fire, Interact. Active while you're playing.
- UI โ Navigate, Submit, Cancel. Active in menus.
- Driving โ Steer, Accelerate, Brake. Active only when in a vehicle.
The power of maps is that you can enable and disable them as a unit. Open the pause menu and you disable the Player map (so pressing Space doesn't jump behind the menu) and enable the UI map. We'll do this in code in the next lesson. Add a map with the + button at the top of the left column.
โ Pro Tip
Keep maps focused. If you find yourself checking "am I in a menu?" inside a gameplay action, that's a sign the action belongs in a separate map you can switch to instead.
Action Types & Control Types
When you select an action, its Properties panel shows an Action Type. This is the single most important choice, because it changes how and when the action reports input:
- Value โ for continuous input that has a current reading, like a movement stick or the WASD vector. It reports a value every frame it's active and does disambiguation (if two controls fight, the strongest wins). Use this for
Move. - Button โ for discrete presses like Jump or Fire. It fires "performed" when pressed and "canceled" when released. Use this for
Jump. - Pass-Through โ like Value but with no disambiguation; every bound control reports independently. Use it for things like reading all keys, or advanced multi-device scenarios.
Alongside Action Type sits the Control Type โ the shape of the data the action produces. The common ones:
- Vector2 โ an X/Y pair, e.g. movement direction. This is what your code reads with
ReadValue<Vector2>(). - Button โ a float that's effectively pressed/not-pressed.
- Axis / Float โ a single number, e.g. a trigger or throttle.
โ ๏ธ Match the Control Type to how you'll read it
If you set Move's Control Type to Vector2 but later call ReadValue<float>(), you'll get a runtime error about a mismatched value type. The Control Type in the editor and the generic type in your code must agree โ Vector2 โ ReadValue<Vector2>().
Bindings & Composites
A binding connects a physical control to an action. For Jump, that's straightforward: one binding from the keyboard's Space key, another from the gamepad's south button. Click the + on the action, choose Add Binding, then use the Path dropdown (or "Listen" and press the control) to pick it.
But Move is trickier. A gamepad stick already produces a Vector2 โ one binding is enough. A keyboard, though, has four separate keys (W/A/S/D) that together make a Vector2. That's what a composite is for.
๐ Definition
Composite binding: several controls combined into one value. The 2D Vector composite takes four button bindings โ Up, Down, Left, Right โ and outputs a single Vector2, exactly like a stick. WASD becomes movement.
To add it: click the action's + โธ Add Up/Down/Left/Right Composite (its full name is "2D Vector"). Unity creates a parent row with four child slots โ assign W, S, A, D to Up, Down, Left, Right. Now the same Move action outputs a clean Vector2 whether the input came from WASD or a stick โ that's the device-agnostic promise in action.
Building the Player Map
Let's assemble exactly what Figure 1 shows.
- Create
PlayerControls.inputactionsand double-click to open the editor. - Under Action Maps, click + and name the map
Player. - Rename the auto-created action to
Move. In Properties, set Action Type = Value and Control Type = Vector2. - On Move, click + โธ Add Up/Down/Left/Right Composite. Assign the four children to
W,S,A,D. - (Optional) On Move, Add Binding and set its path to the gamepad Left Stick, so controllers work too.
- Click + in the Actions column to add a second action
Jump. Set Action Type = Button. - On Jump, Add Binding โ path
Space [Keyboard]. (We'll add the gamepad button in Lesson 3.4.) - Click Save Asset (top-right). Nothing takes effect until you save.
โ ๏ธ Don't forget to Save Asset
The Input Actions editor does not auto-save by default. If you close it or press Play without clicking Save Asset, your changes are lost. (You can tick Auto-Save at the top if you prefer, at the cost of a small delay on every edit.)
You now have a data asset describing your controls. In the next lesson we hook it up to code so pressing WASD actually moves something.
Hands-on Challenge
๐๏ธ Exercise 1: Build the Player map
Objective: Recreate Figure 1 in your own project.
- Create
PlayerControls.inputactionsand add aPlayermap. - Add
Move(Value / Vector2) with a 2D Vector composite bound to WASD. - Add
Jump(Button) bound to Space. - Click Save Asset.
- Expand Move and confirm the four child bindings read W, S, A, D.
๐ก Hint: my composite children are empty
Each child (Up/Down/Left/Right) is its own binding โ select it, then either use the Path dropdown to pick the key or click Listen and press the key. Empty children output nothing.
โ Success check
Your Player map lists Move and Jump. Move shows a "2D Vector" composite with W/S/A/D children; Jump shows a Space binding. The asset saved without the little unsaved-changes asterisk in the title.
๐๏ธ Exercise 2: Add a second map
Add a UI Action Map with a single Navigate action (Value / Vector2) bound to the arrow keys via another 2D Vector composite. You won't use it yet, but it sets up the map-switching you'll do when we build menus later. Notice how the same composite pattern applies to a totally different context.
๐ฏ Quick Quiz
Question 1: Which Action Type should Move use?
Question 2: You want WASD to drive a Vector2 Move action. What do you add?
Question 3: Why would you split controls into a Player map and a UI map?
Summary
๐ Key Takeaways
- Controls live in an .inputactions asset, edited in a three-column visual editor: Action Maps / Actions / Properties.
- An Action Map groups actions for one context (Player, UI) and can be enabled/disabled as a unit.
- Action Type = Value (continuous), Button (press), or Pass-Through (no disambiguation).
- Control Type is the data shape (Vector2, Button) โ it must match how you read it in code.
- A 2D Vector composite turns four keys (WASD) into a single Vector2, just like a stick.
- Always click Save Asset โ the editor doesn't auto-save by default.
๐ What's Next?
You have a data asset full of actions but nothing responds to them yet. In Lesson 3.3: Reading Input in Code we compare the three ways to wire actions to gameplay โ the PlayerInput component, a generated C# class, and direct InputAction references โ and move a character with the new API.
๐บ๏ธ Your controls are now data
Maps, actions, bindings, composites โ you can read and build the Input Actions editor. That asset is the contract every input script in this module will speak to.