Scripting Actions (New Unity Input System)

Tyler Smallwood
3 min readApr 21


Objective: Implement the Actions into Scripting.

Once we have gotten the input actions and bindings set up we will need to generate a C# script from the input actions. To do so we will need to select the input actions in the project windows and in the inspector select Generate C# Class and click Apply.

Now we can see in the Project Window, we can see a new script get created. This script will be the interface between our own script and the input actions. We don’t have to do anything in this script.

Now I’ll create a script named PlayerInput.

Next is to open it and add the library UnityEngine.InputSystem.

Now we will need to have a reference to the PlayerInputActions that the InputActions created. In start we will create a new instance of PlayerInputActions and enable our Dog action map.

Now we will start getting into Delegates and Events. For inputs we will use actions based off the PlayerInputActions. The input actions have three actions we can use, started, performed, and canceled. Started is as soon as you hit the keys, performed is doing it, and canceled is the release of the keys. When typing the += you can hit tab to finish the line and a method will be created.

In each method that was created for started, performed, and canceled, I created a debug.log to give an idea when the key was hit. I added on the OBJ to get an idea of what key was pressed.

Next is to drop this onto the player object.

Now when we go into play mode and we hit the space for Bark, we can see each one be called.

This is a way of checking for the inputs. Thank you for reading and have a wonderful day!



Tyler Smallwood

I am passonate on learning to program and use Unity to become a skillful Unity Developer