Player Input component
About 15 minutes. Optional second workflow.
Learning objectives
- Add a Player Input component that uses the same actions asset
- Wire Move and Jump to Unity Events
- Implement
OnMoveandOnJumpwithInputAction.CallbackContext - Choose this workflow vs
FindActionfor a given script
Use this page after Move a player works. Keep the same Plane and Player cube.
When to use which workflow
| Workflow | How it runs | Use it when |
|---|---|---|
InputSystem.actions.FindAction("Player/Move") | Script looks up the project-wide action | First scripts, one player, fewer Inspector clicks |
| Player Input + Invoke Unity Events | Inspector wires each action to a public method | Designers need to hook events without editing C#; local multiplayer later |
Both read the same Action Maps. Do not run both on the same object at the same time. Player Input also makes a private copy of the actions for that player. Do not also read InputSystem.actions from that object.
This course assignment only requires the FindAction script. This page is extra practice.
1. Disable the first mover
- Select
Playerin the Hierarchy. - On the Player Mover component, clear the enable checkbox.
You should see: Player Mover is still there but disabled. You can delete it instead if you prefer.
2. Add Player Input
- Select
Player. - In the Inspector, select Add Component.
- Choose Player Input.
- Set Actions to the project-wide asset (
InputSystem_ActionsinAssets, or the asset assigned under Edit > Project Settings > Input System Package). - Set Default Map to Player.
- Set Behavior to Invoke Unity Events.
You should see: an Events foldout on the Player Input component, with a Player section listing Move, Look, Jump, Attack, and the other Player actions.
3. Create PlayerMoverEvents
- Select
Assets/Scripts. - Right-click > Create > MonoBehaviour Script (or Create > C# Script).
- Name it
PlayerMoverEvents. - Open the file and replace it with:
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerMoverEvents : MonoBehaviour
{
[SerializeField] float moveSpeed = 5f;
Vector2 moveInput;
public void OnMove(InputAction.CallbackContext context)
{
moveInput = context.ReadValue<Vector2>();
}
public void OnJump(InputAction.CallbackContext context)
{
if (context.performed)
Debug.Log("Jump");
}
void Update()
{
Vector3 delta = new Vector3(moveInput.x, 0f, moveInput.y) * moveSpeed * Time.deltaTime;
transform.Translate(delta, Space.World);
}
}
- Save the file and wait for Unity to compile.
Why this matters: Unity Events for an action fire on started, performed, and canceled.
OnMovestores the latest Vector2, including(0, 0)when the keys are released.OnJumplogs only onperformedso one press does not print three times.
The method names OnMove and OnJump are conventions. The Inspector wiring is what connects them, not the names.
4. Add the script and wire events
- Select
Player. - Add Component > Player Mover Events.
- On Player Input, expand Events > Player.
- On Move, select the +.
- Drag the
Playerobject from the Hierarchy into the object field (or drag the Player Mover Events component). - Open the function dropdown and choose PlayerMoverEvents > OnMove (CallbackContext).
You should see: the Move event lists PlayerMoverEvents.OnMove.

- On Jump, select the +.
- Assign
Playeragain. - Choose PlayerMoverEvents > OnJump (CallbackContext).
If OnMove does not appear, the method is not public, or the parameter is not InputAction.CallbackContext. Fix the script, compile, then wire again.
5. Test in Play mode
- Press Play.
- Click the Game view.
- Use WASD or arrows.
You should see: the cube moves as before.
- Press Space.
You should see: the Console prints Jump.
- Stop Play mode.
Checkpoint
Before you leave this page:
- Player Mover is disabled or removed
- Player Input is on
Player, Default Map is Player, Behavior is Invoke Unity Events - Move and Jump events call
OnMoveandOnJump - In Play mode the cube moves, and Jump logs once per press
If events do not fire, see Troubleshooting.