unity-input
Unity 6 Input System guide. Use when handling player input, controls, gamepad, keyboard, mouse, touch, or XR controllers. Covers the new Input System package (recommended), Input Actions, Action Maps, Control Schemes, PlayerInput component, and input debugging. Based on Unity 6.3 LTS documentation.
Nice-Wolf-Studio · Static checks on file
Installation
Read the source and dependencies before running a command. Copying does not install or execute anything.
npx skills add Nice-Wolf-Studio/unity-claude-skills --skill unity-inputAbout this skill
name: unity-input description: > Unity 6 Input System guide. Use when handling player input, controls, gamepad, keyboard, mouse, touch, or XR controllers. Covers the new Input System package (recommended), Input Actions, Action Maps, Control Schemes, PlayerInput component, and input debugging. Based on Unity 6.3 LTS documentation.
Unity Input System
Input System Overview: New vs Legacy
Unity provides two input systems:
| Feature | New Input System (Recommended) | Legacy Input Manager |
|---|---|---|
| Package | com.unity.inputsystem (v1.19.0 for Unity 6.3) | Built-in (UnityEngine.Input) |
| Architecture | Action-based, event-driven | Polling-based |
| Device Support | Gamepad, keyboard, mouse, touch, XR, custom | Keyboard, mouse, joystick |
| Multiplayer | Built-in local multiplayer via PlayerInput | Manual implementation |
| Rebinding | Runtime rebinding support | Not supported |
| Cross-platform | Control Schemes per device type | Manual per-platform code |
The new Input System is a package installed via Package Manager. It replaces the legacy Input.GetKey/Input.GetAxis API with an action-based model that separates input purpose from device controls.
Namespace: UnityEngine.InputSystem
Quick Start Setup
1. Install the Package
Install via Window > Package Manager > Unity Registry > Input System.
2. Create Default Project-Wide Actions
Go to Edit > Project Settings > Input System Package > Input Actions and click "Create and assign a default project-wide Action Asset".
This creates default Action Maps:
- Player: Move, Look, Jump, Attack
- UI: Navigate, Submit, Cancel
Each action includes bindings for keyboard, gamepad, XR controllers, and touchscreen.
3. Read Input in a Script
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerController : MonoBehaviour
{
InputAction moveAction;
InputAction jumpAction;
void Start()
{
moveAction = InputSystem.actions.FindAction("Move");
jumpAction = InputSystem.actions.FindAction("Jump");
}
void Update()
{
Vector2 moveValue = moveAction.ReadValue<Vector2>();
transform.Translate(new Vector3(moveValue.x, 0, moveValue.y) * Time.deltaTime * 5f);
if (jumpAction.IsPressed())
{
// Jump logic
}
}
}
When multiple actions share names across maps, specify both: "Player/Move".
Input Actions and Action Maps
Core Concepts
- InputAction: A named action that returns control values or triggers callbacks
- InputActionMap: A named collection of related actions (e.g., "Player", "UI", "Vehicle")
- InputBinding: Relationship between an action and a device control
- InputSystem.actions: Reference to project-wide actions
Creating Actions
Method 1 — Input Actions Editor (Recommended): Configure via Project Settings > Input System Package.
Method 2 — MonoBehaviour fields: Declare InputAction fields directly in scripts (configurable in Inspector).
Method 3 — Code:
var moveAction = new InputAction("Move", InputActionType.Value);
moveAction.AddCompositeBinding("Dpad")
.With("Up", "<Keyboard>/w").With("Down", "<Keyboard>/s")
.With("Left", "<Keyboard>/a").With("Right", "<Keyboard>/d");
moveAction.Enable();
Method 4 — JSON: var map = InputActionMap.FromJson(jsonString);
Action Lifecycle
Actions begin disabled. You must call .Enable() before they respond to input. You cannot modify bindings while enabled; call .Disable() first.
Input Action Assets (.inputactions)
These are JSON files storing actions, bindings, and control schemes. Create via Assets > Create > Input Actions.
Auto-generated C# class: Enable "Generate C# Class" in the asset's importer to get type-safe access:
public class MyPlayerScript : MonoBehaviour, IGameplayActions
{
MyPlayerControls controls;
public void OnEnable()
{
controls = new MyPlayerControls();
controls.gameplay.SetCallbacks(this);
controls.gameplay.Enable();
}
public void OnDisable()
{
controls.gameplay.Disable();
}
public void OnMove(InputAction.CallbackContext context)
{
Vector2 move = context.ReadValue<Vector2>();
// Handle movement
}
}
PlayerInput Component
The PlayerInput component maps Input Actions to script methods and handles local multiplayer with device filtering and screen-splitting.
Setup
- Add
PlayerInputcomponent to your player GameObject - Assign your Action Asset to the Actions field
- Select a Default Action Map
- Choose a Behavior notification type
Behavior Options
| Behavior | Mechanism | Best For |
|---|---|---|
| Send Messages | GameObject.SendMessage() | Simple prototyping |
| Broadcast Messages | BroadcastMessage() down hierarchy | Component hierarchies |
| Invoke Unity Events | Inspector-configured event routing | Designer-friendly wiring |
| Invoke C# Events | onActionTriggered, onDeviceLost, onDeviceRegained | Programmer control |
Send Messages Pattern
public class PlayerActions : MonoBehaviour
{
public void OnJump()
{
// Called when Jump action triggers (no parameters)
}
public void OnMove(InputValue value)
{
Vector2 v = value.Get<Vector2>();
// InputValue is only valid during this callback
}
}
Unity Events Pattern
public void OnFire(InputAction.CallbackContext context)
{
if (context.performed)
{
// Fire logic
}
}
Managing PlayerInput
PlayerInput playerInput = GetComponent<PlayerInput>();
playerInput.DeactivateInput(); // Disable all input
playerInput.ActivateInput(); // Re-enable with default map
playerInput.Swit
Read the complete source ↗