Unity Input System, from Basic Principles

Eyas
8 min readFeb 25, 2021

In the third installment of the Unity for Software Engineers series, we cover Unity’s Input System from basic principles.

Handling player input will likely be among the first game systems you implement. Unity Technologies unveiled a new Input System in 2019 intended to replace their previous system. While the new Input System allows building on more idiomatic Unity patterns, it can also be more challenging for a newcomer to pick these up. This is especially true because the Input System leans on configurable assets and emphasizes Editor usage. The Input System’s Quick start guide is helpful, but only once the Input System and Unity Events’ basic concepts are understood.

Much of the newer pieces of the Unity Engine are being released as encapsulated packages. Unity packages are installed from the Unity Package Manager UI in the editor (open it in Window > Package Manager). The package updates a manifest.json file that has a "dependencies" entry identical to a package.json. The
package manager resolves dependencies and writes to a package-lock.json. You can install the Unity Input System from the Package manager, which adds a dependency on com.unity.inputsystem in your manifest.

The Input System makes it easy to create player-configurable cross-platform game controls through assets known as Input Action Maps. The system also exposes an Editor- and event-based interface to specify Input behavior.

Programmatic Use

If you’d like to make progress on a proof of concept quickly, you might initially choose to sidestep Input Action maps and programmatically interrogate the inputs.

Here’s a basic example covering the most important concepts:

or:

--

--

Eyas

Software Engineer living in Brooklyn, NY. MIT Computer Science S.B. ’13, M.Eng. ‘14. From Amman, Jordan. Interested in politics, current affairs, and technology