Unity 2019.3 New Input System

Unity 2019.3 New Input System

Unity 2019.3 New Input System 1024 576 New_bluecreazione

New technology has dramatically changed how we play and consume media in recent years. Every new wave of technology also brings new devices along with specific control requirements.
Yesterday I installed latest 2019.3.0f1, in this version, Unity introduced new Input System in Preview packages. I feel it’s specifically for Controllers.
The new Input system is built from ground up with ease of use, consistency across platforms and flexibility in mind.

How to import new input system into project

To get started you will need to create a new Unity Project or open a project you want to add the new input system in. Navigate to the “Window” > “Package manager”. You will then need to select the “Advanced” menu and select “Show preview packages”. After click on import button, New input system will be successfully added into unity project. However you will need to restart Unity.

Add C# script for input system

Click on Project and select “Input system” from Drop down and rename it. After that, input system tab will open and Three fields are present which are Action Maps, Actions and Properties.
Add a new Action map and after that create new Action as per your game needs, then click on Binding. In Property Window you can select the binding path from Drop down or simply connect your game controller and click on listen and press the button you want to select for performing action.
After Adding all the Actions into Action map, select the file you created for Input system and in inspector select the Generate C# script. This will generate C# Script for you, you don’t need to write on this script. Now create new script to make use of this C# file. and define all the game actions into void Awake() method.

I am just write sample code for your reference.

ActionControl controls; // ActionControl is the C# file unity made for us.
void Awake()
controls = new ActionControl(); // Initialize
controls.Gameplay.Punch.performed += ctx => Punch();
// Gameplay is the ActionMap and Punch is the action. “ctx” is Context.
//performed is the type of event. It can also be cancelled. However we want to listen to Button Down so Performed is for us here.
void Punch()
{ //Anything you want to do when Punch Action is called.

Bug in New Input System

After Adding all the actions into action map and adding the script, I tested on two devices by connnecting my game controller to mobile using bluetooth.

After testing, result varied on different devices, in moto g5(s) plus, some of the actions are not performed as i defined in action map but in ASUS Zenfone max pro M1, actions are performed as defined and they are similar to what we observed on Windows 10. Controller we used was PS4 Controller.

So for now, I will wait before we update our current game’s input system to Unity’s input system. We still haven’t tested on IOS to see if the results are the same. That will be done shortly. If we find that IOS works similar to Windows then I guess it’s fair to say that New Input System works 90% of times. And definitely this new system seems clean and simple to implement. So everyone should try to see if their project needs this.

However, I hope Unity will resolve this bug in their future releases.

If you want help implementing New Input System in your project do let me know. We will be happy to help you out.

1 comment
  • Jasper December 20, 2021 at 4:45 am

    Hi! I could have sworn I’ve visited this web site
    before but after going through a few of the articles I
    realized it’s new to me. Anyways, I’m certainly pleased I found
    it and I’ll be bookmarking it and checking back often!

Comments are closed.