Creating Your First Action Using Unity’s New Input System

Objective: To learn how to create your first Action using Unity’s New Input System.

Apex Legends Action Maps/Actions — reddit.com

What is an Action

An Action is something that triggers a callback in response to player input.

E.g. If we were in a UI menu of a game, usually the A and B buttons on an Xbox controller allow you to proceed forward or backwards in the menu.
Alternatively if we were in game, A might jump and B would crouch.

Pressing any keys/buttons that have been mapped for player input, would trigger a callback response to perform an Action.

How to Add an Action to an Action Map

There are 4 different ways you can create an Action including:

  1. Using the Action Editor
  2. Embedding them in MonoBehaviour Components
  3. Manually loading them from JSON, or
  4. Creating them directly in code.

This article is going to look at creating Actions through the Action Editor.

With the Input Action Window open, simply press the ‘+button in the Actions section:

Adding a new Action to the selected Action Map

This will automatically add a new Action for us to rename, along with a key binding for us to choose:

Creating an Action and Action Type

For this example I am going to create a ‘JumpAction and map this to the ‘Spacekey by first renaming the Action.

When you added the Action you will also now see a third section called ‘Action Properties’. Let’s leave the ‘Action Type’ as ‘Button’ for now, but there are a few other options to choose from.

Now click in the ‘No-Bindingfield. This will bring up a new section called ‘Binding Properties’, which will allow us to map our key:

Selecting a key binding for our Action

When we click in the ‘Pathdrop down field, a new pop up window appears giving us a few different options as to how we want to locate the ‘Space’ key:

Listen Pop Up Window

Search Box - Typing ‘Space’ will show the key to map.

By Location of Key - This will bring up a drop down box which we can cycle through to find the key.

By Character Mapped to Key - Shortened list compared to above.

Listen Button - The easiest option here to use, which when clicked will wait for your input and map it to the key pressed:

Pressing the ‘Space’ key after clicking the ‘Listen’ button

You can also have many different bindings all pointing to the same Action.

Lastly, you always want to make sure you are saving your asset before closing out of the window:

Saving Your Asset

You have now created your Action Maps first Action with it’s associated binding!

Next Article

“Scripting Actions in Unity’s New Input System”

--

--

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