CodeBlanks Logo Icon CodeBlanks

The new Input System

Briefly learn the differences between the old and new Input System.

Legacy vs New Input System

The Input class (legacy input manager) used for years in Unity is quick for simple prototypes, but lacks proper multi-device, gamepad, and key re-binding support. To solve these shortcomings, Unity developed the modern and modular Input System package. The new system is added to the project via the Package Manager.

// The new system is installed via Package Manager:
// com.unity.inputsystem

Input Actions

At the heart of the new Input System lies Input Actions. Instead of hardcoding key names (e.g. W key), you define an abstract action (e.g. "Move" or "Jump"). This makes it possible to bind keyboards, gamepads, or touch controls to the same action without touching the code.

// Action-based approach:
// "Jump" action can bind to both Space and Gamepad button South.

Practice Input Action State Check

If the simulated InputAction object's IsTriggered() method is true, print Debug.Log("Eylem tetiklendi");.

Starter code

Player.cs
using System;

public class InputAction
{
    public string Name { get; set; }
    public bool IsTriggered() => true;
}

public static class Debug
{
    public static void Log(object message) => Console.WriteLine(message);
}

public class Program
{
    public static void Main()
    {
        InputAction jumpAction = new InputAction { Name = "Jump" };
        // jumpAction tetiklenmisse "Eylem tetiklendi" yazdir
    }
}

Sample solution

Player.cs
using System;

public class InputAction
{
    public string Name { get; set; }
    public bool IsTriggered() => true;
}

public static class Debug
{
    public static void Log(object message) => Console.WriteLine(message);
}

public class Program
{
    public static void Main()
    {
        InputAction jumpAction = new InputAction { Name = "Jump" };
        if (jumpAction.IsTriggered())
        {
            Debug.Log("Eylem tetiklendi");
        }
    }
}

Expected output

Eylem tetiklendi

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which tool is used to include Unity's modern Input System package into a project?

  • Console Window
  • Package Manager Correct answer
  • Hierarchy Window
  • Build Settings

Explanation: Because the new Input System is an independent package, it is installed from Window > Package Manager.

2 New Package Name

Question
string paketAdi = "com.unity.____";
Answer
string paketAdi = "com.unity.inputsystem";

Explanation: Unity's new input package is identified as com.unity.inputsystem in Package Manager.

3 System Comparison

Term Meaning
Klasik Input Built-in system using GetKey / GetAxis
Package Manager Where the new Input System is installed
Input Action Structure binding keys to actions
Re-binding Changing key bindings in-game

All lessons in Beginner