Unity – An introduction to the New Input System

This guide shows how to read inputs directly in your scripts using the class generated by Generate C# Class/Script—no Player Input UnityEvents and no helper components. Just a simple and straightforward way of reading inputs using the new input system.

0.- What is the new input system? #

Unity’s Input System is a newer way to handle input from keyboard, mouse, gamepad, touch, and VR/AR. Instead of checking keys one by one, you first name what the player wants to do—like Move or Jump—and then connect those actions to the controls you want. All of this lives in a small settings file you can edit without changing your game code.

Core ideas (in simple terms)

  • Input Actions asset (.inputactions): A settings file that stores all your control setup.
  • Action Maps: Groups of actions (like Player, UI, or Vehicle). You can turn a whole map on or off at once. You can think of them like folders that contain a specific action group.
  • Actions: Things the player does (e.g., Move, Look, Jump). Actions have types:
    • Value: gives data like a direction (Vector2) or a number (float). Useful for joysticks, triggers or directional input.
    • Button: pressed or not pressed.
    • Pass‑Through (optional/advanced): sends the raw input without extra buffering.
  • Bindings: The actual controls that drive an action (like WASD or the Left Stick). You can add several bindings to the same action.
  • Composites: Bindings made from parts, like a 2D Vector that combines W/A/S/D or a stick into one direction.
  • Interactions: Rules for when an action counts, like Press, Hold, or Tap.
  • Processors: Small filters that change the value, like Deadzone, Invert, or Scale.
  • Control Schemes: Named device sets (like Keyboard&Mouse or Gamepad) that help the game switch devices and support rebinding.

Two ways you can use it

  1. Generated C# class (this guide): Click Generate C# Class on your asset to make a helper class (for example, InputManager). In code, create it, enable the maps you need, then read values with ReadValue<T>() or listen for action events (.started, .performed, .canceled).
  2. Components (FYI): Player Input and Player Input Manager use UnityEvents and can handle local multiplayer. We’re not using them here, but they’re handy for no‑code setups.

0.1.- Prerequisites #

  1. Install the Input System: Window ▸ Package Manager ▸ Unity Registry ▸ Input SystemInstall.
  2. Activate it: Edit ▸ Project Settings ▸ Player ▸ Other SettingsActive Input Handling = Input System Package (New) (or Both if you must keep the old system).
  3. (Optional for UI) Ensure your scene has an EventSystem with InputSystemUIInputModule.

1.- Create an Input Actions asset #

On any folder of your project:

  1. Create: Right‑click ▸ Create ▸ Input Actions → name it (e.g., InputManager).
  2. Open the asset and add an Action Map called Player.
  3. Add actions:
    • Move (Value ▸ Vector2)
    • Look (Value ▸ Vector2)
    • Jump (Button)
    • Attack (Button)
  4. Add bindings (WASD/Left Stick for Move, Mouse Delta/Right Stick for Look, Space/A for Jump, Mouse Left/RT for Fire, etc.).
  5. Save the asset.

1.1.- Generate the C# class #

From the asset’s inspector or the Input Actions window menu, click Generate C# Class (a.k.a. Generate C# Script). Choose a filename (e.g., InputManager.cs). After compilation, you can do:

🔷
var input = new InputManager();
input.Player.Enable();
var move = input.Player.Move.ReadValue<Vector2>();

2.- How to read inputs #

2.1.- Read a button (Jump, Attack…) #

2.2.- Read a Vector2 (Move, Look…) #