What if you could change your game controls anytime without rewriting your code?
Why Input action maps in Unity? - Purpose & Use Cases
Imagine you are making a game where the player can jump, run, and shoot. You write separate code to check every key press manually, like checking if the spacebar is pressed for jump or if the mouse button is clicked for shooting.
This manual way gets messy fast. You have to write many if-statements, and when you want to change controls or add a new action, you must hunt through your code to update everything. It's easy to make mistakes and hard to keep track of all inputs.
Input action maps let you group all player actions and their controls in one place. You define actions like 'Jump' or 'Shoot' and assign keys or buttons to them. Then your game listens for these actions instead of raw keys, making your code cleaner and easier to manage.
if (Input.GetKeyDown(KeyCode.Space)) { Jump(); } if (Input.GetMouseButtonDown(0)) { Shoot(); }
playerInput.actions["Jump"].performed += ctx => Jump(); playerInput.actions["Shoot"].performed += ctx => Shoot();
You can easily change controls, support multiple devices, and keep your input code organized and scalable.
In a multiplayer game, you want players to customize their controls. Input action maps let you save and load different control schemes without rewriting your game logic.
Manual input checks become hard to manage as your game grows.
Input action maps group actions and controls cleanly.
This makes your game easier to update and supports flexible control setups.