Exploring the Different Action Types in Unity’s New Input System

Chris Hilton
5 min readOct 31, 2022

Objective: To understand the differences between the 3 Action Types in Unity’s New Input System and when to use them.

Xbox One Controller GIF Tenor

What is an Action Type?

This determines how an Action is triggered (through events) and has 3 possible options:

  • Value,
  • Button, and
  • Passthrough.

Value

Value should be used for continuous detection of inputs, where it is always looking for a change of state.

E.g. Movement using a thumbstick on a controller.

Value also has an initial state check when the game is run, compared to the ‘ButtonAction Type which doesn’t have one (discussed further down).

E.g. Let’s use an Action Type of ‘Value’ with a Control Type of ‘Vector2’ to represent a 2D-axis. If we move the thumbstick either left, right, up or down we will get a value of 1 or -1 depending on positive/negative movement respectively. If we don’t provide an input, the default value is 0.

As you can see if I want to use my doggo’s nose as a thumbstick, you will see the actual thumbstick return to it’s default position resulting in a value of 0.

Doggo nose thumbstick

All of these changes in values, represent a change in state. This change will determine what event phase we are in.

Game Console Joystick GIF

E.g. Moving the thumbstick from it’s starting position (value — 0) to the right will trigger 2 events, ‘Start’ and ‘Perform’ as it is considered a change in state.

However, there is a difference between the ‘Start’ and ‘Performevents after moving away from the default value.

The ‘Performevent will continue to trigger for every new value it changes to.

The ‘Startevent will only trigger after it has returned to it’s default value and moved away again.

E.g. With this example below I have moved the left thumbstick on an Xbox Controller left and then anti-clockwise in a full loop. Notice how we only get one ‘Started’ event, whilst the ‘Perform’ event continually gets triggered for every new value until I let go of the thumbstick and it returns to 0 where the ‘Canceled’ event gets triggered.

Testing the ‘Started’, ‘Performed’ and ‘Canceled’ events for the Action Type — Value.

There is also a large range of ‘Control Types’ to be used depending on your projects requirements. In my case I have been using Vector2 for input testing.

Control Type list for the Action Type — Value

Disambiguation

When we have multiple controls bound to the same Action, how does the Input System know which one to use?

Through the disambiguation process, using the Controls magnitude.

During this process the Input System keeps track of the values of each control attached to the same Action. If at any time the magnitude of one control is greater than the magnitude of another control, then this control will be the one ‘driving’ the Action.

If you don’t want the Action you are performing to use this process, you can set the ‘Action Type’ of the binding to ‘Pass-throughinstead of ‘Value’, as ‘Pass-throughskips over this process.

E.g. Imagine you are sitting in front of your desktop playing a fast paced FPS with your Xbox Controller and in the moment of a heated fight your controller dies. You have 2 options at this point, frantically look for your charging cable/new batteries whilst you scream at your screen “WHY NOW, #!%#” and most likely will die..

Or,

If you have the luxury, you could simply turn on your other controller and keep going as if nothing happened.

Button

The button is designed for triggering an event when a button has been pressed. It returns a float value of either 1or 0 depending on whether a button has been pressed or not (1 pressed and 0 not).

E.g. If we continue to use the Xbox Controller example, pressing A, B, X or Y are great examples of this.

Xbox Controller — A, B, X and Y buttons
Pressing a button will result in a float value of 1 and when released, 0.

Compared to ‘Value’, ‘Button’ does not use continuous state detection and doesn’t have Control Type options.

Action Type — Button, not having a Control Type.

There is also no initial state check unlike ‘Value’. If you start a game and have a button held down such as ‘A’, it won’t register an event until you have released the button and pressed it again.

Pass-through

Is similar to ‘Value’, except it ignores the ‘disambiguation’ process.

It also doesn’t use the initial state check, unlike ‘Value’.

When comparing a ‘ValueAction Type to the ‘Pass throughAction Type, a ‘Valueaction will respond immediately to a controls current value where as the ‘Pass through’, will not explicitly start or ever cancel. It will only continue to ‘Perform’ for every value change on any button control.

Next Article

“2D Vector Composite Binding in Unity’s New Input System”

--

--