In this lesson, you will learn how to organize your game's controls by creating an Input Action Asset to group inputs into logical Action Maps.
Why Use Action Maps?
In the legacy input system, checking every key manually can become messy as your game grows. The new Input System uses an Input Action Asset—a file that sits in your Project window—to act as a central hub for all your controls. Within this asset, you categorize your inputs into Action Maps.
Think of an Action Map like a "control profile." For example, you might create one map called Player for walking and jumping, and a separate map called UI for navigating menus. By grouping these, you can enable or disable entire sets of inputs at once. If your player opens a menu, you can simply "disable" the Player map so they don't accidentally jump while typing in a text box!
Creating Your Asset
- Right-click in your Project window.
- Select Create > Input Actions.
- Name it
PlayerInputActions. - Double-click to open the Input Action Editor.
Organizing Actions
Inside the editor, you will see a pane on the left for Action Maps. Click the + icon to create a new map (e.g., Player). Inside that map, click the + icon again to add an Action (e.g., Move).
Actions are the specific things the player does, like "Move" or "Jump." When you select an Action, you add Bindings to it. A binding connects a physical button (like the W key or a Gamepad Stick) to that Action.
Once your asset is configured, you don't need to write long if statements to check for key presses. Instead, your scripts will reference the asset:
// Example of how we structure our input logic
void EnableGameplay() {
playerInputActions.Player.Enable();
playerInputActions.UI.Disable();
}
By separating your inputs into these distinct "Map" containers, your code stays clean and your game logic remains decoupled from the specific hardware being used.
Key Takeaway: Action Maps allow you to group related controls together, making it easy to toggle entire systems of input on or off depending on the game state.