The new Input System
- Game Development course
- Beginner
- Lesson 46/83
- 4 min
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.inputsystemInput 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
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
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
string paketAdi = "com.unity.____";
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 |