Input Actions

About 10 minutes.

Learning objectives

The three pieces

Do not design a custom map yet. Learn the default asset first.

Term What it is Example in the default asset
Action Map A group of actions for one situation Player, UI
Action A named thing the game cares about Move, Jump, Submit
Binding A control that triggers that action W/A/S/D, arrow keys, gamepad left stick

Your script asks for Player/Move. It does not ask for the W key. Bindings can change later. The action name stays the same.

Why this matters: Always use the map/action path (Player/Move), not just "Move". If two maps ever share a name, FindAction("Move") is ambiguous. FindAction("Player/Move") is not.

Official overview: Quickstart Guide | Input System

Open the default asset

  1. Open Edit > Project Settings > Input System Package.
  2. Confirm the project-wide Action Asset is assigned.
  3. Double-click the asset in the Project window (InputSystem_Actions.inputactions under Assets), or use the Input Actions editor shown in Project Settings.
![Input Actions editor showing Player map](images/04-input-actions-editor.png)

You should see: two maps, Player and UI, and a list of actions on the selected map.

Walk through Player/Move

  1. Select the Player map.
  2. Select the Move action.
  3. Read Action Type / control type. Move is a Value action with a Vector2 control type.
  4. Expand its bindings.

Typical default bindings for Move:

ReadValue<Vector2>() therefore returns:

In a 3D scene you usually apply x to world X and y to world Z.

Walk through Player/Jump

  1. Stay on the Player map.
  2. Select the Jump action.
  3. Read the control type. Jump is a Button.
  4. Expand its bindings.

Typical default bindings for Jump:

Buttons are not Vector2. In code you use WasPressedThisFrame(), IsPressed(), or a callback's context.performed. You do not call ReadValue<Vector2>() on Jump.

The UI map (do not edit)

Select the UI map. You should see actions such as Navigate, Submit, and Cancel. Leave them. They feed the Input System UI Input Module if you add a Canvas later.

Control types you will use in this course

Control type Typical action How you read it
Vector2 Move, Look, Navigate action.ReadValue<Vector2>()
Button Jump, Attack, Submit action.WasPressedThisFrame() or action.IsPressed()

Match the read method to the action type. A type mismatch compiles in some cases and then returns a useless default.

Optional: add one binding

You do not need this for the cube assignment. Use it if you want to see a binding get created.

  1. Select Player > Jump.
  2. Select the + next to Bindings.
  3. Choose Add Binding.
  4. Select the new binding's Path.
  5. Choose Listen, then press the key or pad button you want (for example E).
  6. Save the asset if the Input Actions window shows unsaved changes (Ctrl/Cmd+S).

You should see: Jump lists the new path under Bindings.

To remove it, select that binding and delete it, then save. Leave the original Space and gamepad south bindings in place.

Why actions beat hard-coded keys

This is the wrong pattern in this course:

// Do not do this. Input.GetKey is legacy Input Manager.
if (Input.GetKey(KeyCode.W)) { /* ... */ }

Problems:

The right pattern:

Vector2 move = moveAction.ReadValue<Vector2>();

Same line for keyboard composites and for a stick.

Checkpoint

Before you continue to Move a player: