Converting to the new input system

Documenting how to convert to the new input system in Unity. Methods may be refined and are subject to change.

Go to Window > Package Manager. Search for input in the unity registry. Install. The project will ask you if you want to change to use the new input system exclusively. I usually hit “No” and then go to Edit > Project Settings > Player > Active Input Handling > Both > Apply > Save. This allows you to use both input systems at the same time. Advanced users may just want to only use the new input system.
Create a new empty GameObject. Add component “Player Input”
Click Create Actions… I will name the action asset “GameInput”. After it is created in the project window, I will move it to Asset > Settings > Input. You could similarly create this action asset by just right clicking in the project window Create > Input Actions. However, this second method will not give any preconfigured input actions, and I think it’s nice to have some basic ones to start with.
The Input Action asset will open. It is broken down into Action Maps, Actions, and Action Properties. Within Actions is where you can change the bindings of the Actions. Here, I will rename “Fire” to “Jump” since that’s what we will need for this game.
Click the dropdown on Jump. Here you can change the bindings for the particular action. Click on Right Trigger. On the binding properties on the right, search for Button South on the gamepad as we want to change the binding from Right Trigger on gamepad to Button South on gamepad for the “Jump” action. (You can change to whatever you like any time.) You can either type this in the box, search for it using the selection below, or click “Listen” where Unity will listen for your next input from any device. Similarly, click on “Left Button [Mouse]” under the Jump action. We also want to bind Space on keyboard to this action. Click Save Asset to save your changes. Move or close this window when you are done.
Find the action asset you created. Click Generate C# class in the inspector. This is automatically updated whenever you make changes to the Input Action Asset. Move the C# script to be generated to the location you want. This will regenerate a new file there every time you load the game so change the location here if you need to move the class.
Find your EventSystem in the hierarchy. Replace with InputSystemUIInputModule
This component will change to look like this. On the Actions Asset, choose the input asset that you created earlier. In this case, “GameInput”

Next, we are going into the code to rewire the old system with the new. Open the player script.

We’ll need the UnityEngine.InputSystem namespace
Create a reference to your move and jump actions. You will choose these in the inspector. Create on Enable and OnDisable callback functions to enable these actions and then subscribe to a method we will create.
Right click on the error to quickly create a method.
Copy the old jump logic into the function. Comment out the old logic.
Likewise we will need to read the move value from our action in update. You can comment out the old logic.
Back in the inspector, remember to choose which action reference you would like.

From here, the basics should be hooked up. A few extra tips are seen below.

Cinemachine also provides integration with the input system. Add component “Cinemachine Input Provider” to the Player VCam
You can select what actions are used for input. Here, we choose Player/Look for the XY Axis. You may need to adjust sensitivity settings after this change.
Design a site like this with WordPress.com
Get started