【Unity】Getting Started with Unity's New Input System: Accelerate Development with Next-Gen Input Handling

Created: 2026-02-05

Learn how to use Unity's New Input System. Implement cross-platform input handling using Input Actions, Bindings, and the Player Input component.

Overview

Tested with: Unity 2022.3 LTS / Unity 6

"I want controls that work with both keyboard and gamepad." "I want players to be able to customize their key bindings." If you have ever struggled to achieve these goals with the old Input System, the New Input System is here to help.

New Input System is the next-generation input handling system introduced in Unity 2019. It uses an abstracted concept called Input Actions to achieve flexible, device-independent input processing.

Installation and Initial Setup

Installing the Package

  1. Open Window > Package Manager
  2. Select Unity Registry from the dropdown at the top-left
  3. Search for Input System and install it
  4. Click "Yes" when prompted to restart

Configuring Active Input Handling

  1. Open Edit > Project Settings > Player
  2. Check Other Settings > Configuration > Active Input Handling
  3. Select Both or Input System Package (New)
  4. The Editor will restart

Both: Allows using both the old and new Input Systems simultaneously. Useful during the migration period.

Differences from the Old Input System

Problems with the Old Input System

  • Required separate code for each device
  • Difficult to customize key bindings
  • Cross-platform support was cumbersome
  • Local multiplayer was difficult to implement

Advantages of the New Input System

  • Device-independent implementation - Same code works across multiple devices
  • Cross-platform support - Centrally managed via configuration files
  • Key binding customization - Provided as a built-in feature
  • Local multiplayer support - Easily implemented with the Player Input component
  • Complex input patterns - Long press, double-click, etc. achieved through configuration alone

Components of the New Input System

ElementDescription
Input Actions AssetA file that stores input configuration
Action MapA group of related Actions
ActionA unit of operation (movement, jump, etc.)
BindingLinks an Action to an actual input device
Player InputA component that receives input events

Action Type

TypeUse Case
ValueContinuous values (movement stick, triggers, etc.)
ButtonButton press state (jump, attack, etc.)
Pass-throughPasses input directly (handling multiple input sources)

Creating and Configuring Input Actions

Creating an Input Actions Asset

  1. Right-click in the Project window
  2. Select Create > Input Actions
  3. Double-click the asset to open the editing window

Creating an Action Map

Click the + button at the top-left to add a new Action Map (e.g., "Player")

Creating an Action

  1. Click the + button with an Action Map selected
  2. Enter an Action name (e.g., "Move", "Jump")
  3. Configure the Action Type and Control Type

Adding Bindings

Example for WASD keys:

  1. Select the "Move" Action
  2. Click + and choose Add Up/Down/Left/Right Composite
  3. Set Up: W, Down: S, Left: A, Right: D

Adding a gamepad left stick:

  1. Select the same "Move" Action
  2. Click + and choose Add Binding
  3. Select Gamepad > Left Stick in the Path

Multi-device support: By adding multiple Bindings to the same Action, the same code works for both keyboard and gamepad.

Generating a C# Class (Recommended)

You can auto-generate a type-safe class from the Input Actions Asset.

  1. Select the Input Actions Asset in the Project window
  2. Check Generate C# Class in the Inspector
  3. Set the Class Name (e.g., PlayerInputActions)
  4. Optionally set a Namespace
  5. Click Apply

This generates PlayerInputActions.cs, which can be instantiated with new PlayerInputActions().

Script Implementation

Choosing the Right Approach

MethodBest For
Player Input + Unity EventsSmall projects, prototyping, when non-programmers need to modify settings
C# Class GenerationMedium to large projects, type-safe implementation, complex input handling

Method 1: Player Input + Unity Events

The Player Input component lets you link Actions to methods in the Inspector.

Configuring the Player Input Component

  1. Add a Player Input component to the GameObject
  2. Set the Actions to the Input Actions Asset
  3. Change Behavior to Unity Events
  4. An Events section appears
  5. Register methods for each Action
using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerController : MonoBehaviour
{
    private Vector2 moveInput;

    public void OnMove(InputAction.CallbackContext context)
    {
        moveInput = context.ReadValue<Vector2>();
    }

    public void OnJump(InputAction.CallbackContext context)
    {
        if (context.performed)
        {
            Debug.Log("Jump!");
        }
    }
}

Method 2: C# Class Generation (Recommended)

using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerController : MonoBehaviour
{
    private PlayerInputActions inputActions;
    private Vector2 moveInput;

    void Awake()
    {
        inputActions = new PlayerInputActions();
        inputActions.Player.Move.performed += OnMove;
        inputActions.Player.Move.canceled += OnMove;
        inputActions.Player.Jump.performed += OnJump;
    }

    void OnEnable() => inputActions.Enable();
    void OnDisable() => inputActions.Disable();

    void OnDestroy()
    {
        // Unsubscribe event handlers (prevent memory leaks)
        inputActions.Player.Move.performed -= OnMove;
        inputActions.Player.Move.canceled -= OnMove;
        inputActions.Player.Jump.performed -= OnJump;
        inputActions.Dispose();
    }

    private void OnMove(InputAction.CallbackContext context)
    {
        moveInput = context.ReadValue<Vector2>();
    }

    private void OnJump(InputAction.CallbackContext context)
    {
        Debug.Log("Jump!");
    }
}

Preventing memory leaks: Unsubscribe event handlers with -= in OnDestroy and call Dispose() to prevent memory leaks when the object is destroyed.

Switching Action Maps

You can switch the active Action Map between gameplay and UI operations.

public class InputManager : MonoBehaviour
{
    private PlayerInputActions inputActions;

    void Awake()
    {
        inputActions = new PlayerInputActions();
    }

    // During gameplay: Enable Player map, Disable UI map
    public void EnableGameplayInput()
    {
        inputActions.Player.Enable();
        inputActions.UI.Disable();
    }

    // During UI interaction: Enable UI map, Disable Player map
    public void EnableUIInput()
    {
        inputActions.Player.Disable();
        inputActions.UI.Enable();
    }
}

Example use case: Switch to the UI map when the pause menu is opened, and switch back to the Player map when it is closed. This prevents the character from moving during menu navigation.

Interactions and Processors

Interactions

InteractionUse Case
HoldFires on long press
TapDetects short taps
Multi TapDetects consecutive taps such as double-click

Processors

ProcessorUse Case
NormalizeNormalizes vectors (corrects diagonal movement speed)
InvertInverts input values
ScaleScales input values (sensitivity adjustment)
Dead ZoneIgnores slight stick tilts

Device Connection/Disconnection Detection

You can detect device state changes, such as plugging and unplugging gamepads.

using UnityEngine;
using UnityEngine.InputSystem;

public class DeviceManager : MonoBehaviour
{
    void OnEnable()
    {
        InputSystem.onDeviceChange += OnDeviceChange;
    }

    void OnDisable()
    {
        InputSystem.onDeviceChange -= OnDeviceChange;
    }

    void OnDeviceChange(InputDevice device, InputDeviceChange change)
    {
        switch (change)
        {
            case InputDeviceChange.Added:
                Debug.Log($"Device connected: {device.displayName}");
                break;
            case InputDeviceChange.Removed:
                Debug.Log($"Device disconnected: {device.displayName}");
                break;
        }
    }
}

Example use case: Show a pause screen when a gamepad is disconnected, or display a "Controller detected" notification when one is connected.

Common Issues and Troubleshooting

Input Not Responding

  • Verify that inputActions.Enable() is called in OnEnable
  • Check that the Action Map is enabled
  • Verify that Bindings are configured correctly
  • If not included in the build: Check the Input Actions Asset settings (see below)

Input Actions Asset Not Included in Build

To include the Input Actions Asset in the build, use one of the following methods:

  1. Reference via Player Input component - Reference it in a Player Input component attached to a GameObject
  2. Reference from script - Reference the asset with [SerializeField]
  3. Register as Addressable - Manage it as an Addressable Asset

Note: The "Preload" checkbox that existed in Input System 1.1 and earlier has been deprecated (Unity 2021+). Reference the asset using one of the methods above.

Movement Doesn't Stop

Register the canceled event as well:

inputActions.Player.Move.performed += OnMove;
inputActions.Player.Move.canceled += OnMove;

Why can you use the same method?: When the canceled event fires, context.ReadValue<Vector2>() automatically returns Vector2.zero. Therefore, using the same OnMove method for both performed and canceled correctly sets Vector2.zero when there is no input.

Diagonal Movement is Too Fast

  • Set the Composite Binding Mode to "Digital Normalized"
  • Or add the "Normalize Vector 2" Processor

Summary

The New Input System has a steeper learning curve, but offers powerful features that make it worthwhile.

  • Input Actions for device-independent input handling
  • Action Maps for context-sensitive input switching
  • Bindings to assign the same Action to multiple devices
  • Interactions and Processors for complex input patterns through configuration alone
  • C# Class Generation for type-safe implementation

Start with simple movement and jump, then gradually take on more complex features.

Further Learning