Galaxy Shooter 2D — New Input System #17

Ditching the old Unity Input System for the new and improved one

You’ve probably heard already about the new Unity Input System, which allows for more complex input handling behaviour and flexibility than the old system it had. Honestly, if you are still using the old one, I truly recommend you to switch. It will make your life easier!

Up until now, I have been using the old one to quickly prototype the game. I will explain in this article how I switched and the basic use of the New Input System.

Switching from Old to New

The New Input System comes as a Unity Official Package (use Unity version 2018 or newer). You can find it and install it in the Package Manager window (Window > Package Manager).

Once you install it, a new window will pop-up asking you if you want to completely disable the old Input System from your Unity project. That’s up to you. You could exclusively use the new one, or both at the same time if you’d like. If you later change your mind, you can always change it in Project Settings > Player > Active Input Handling .

Creating Input Actions

Add a Player Input component to your Player Controller (in my case, my Player Ship), and click on the Create Actions… button. A new window will show up asking for a location to store a file with all your future inputs.

Now click on the newly generated file, and click on Edit Asset (or just double click it). A special window will open, displaying some action maps generated by default.

The Move and Fire Actions are the only actions I need for now. I’ll let you explore a bit on your own how to create new maps and actions. Try to play with it (that’s how most of us learnt).

Using Inputs

There are various ways to handle these Inputs, but the one I chose to use is through Invoking Unity Events in the Player Input component.

If you click on the Events dropdown, the Editor will show a list with Input Action events, which they all pass a InputSystem.CallbackContext value. In code, we must create a public method with a parameter of that type.

Because the CallbackContext doesn’t return any value, we must access the method ReadValue<>() to obtain it.

The Shoot (Fire) Input Map has a Press interaction with a “Press and Release” behaviour. That means that whenever the Control magnitude crosses or goes back below the Press Point threshold.


This was rather a small and brief introduction to the new Input System, but good enough to get you going. I always suggest you look at some other in-depth videos, and once you get a grip of the system, take a look at the API.




Junior Unity Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Get Started with Koa.js

Use WebCam in Angular simplified

Remove Null, None, and Empty Strings from an n-sub level dictionary

A Quick Introduction to Typescript

An approach to a Nest notification module

GitHub & Medium with Embedly

React Fundamentals

Number of Provinces

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pablo Gómez Platón

Pablo Gómez Platón

Junior Unity Developer

More from Medium

2D Player Animation (part 2)

Journal 137 — Unity App Development, AR Demo Add UI

Creating a Moving Platform in Unity

Mastering Unity Scripting by Alan Thorn

Cover of the Mastering Unity Scripting book