INPUT • CONFIGURATION ERROR

InvalidOperationException: You are trying to read Input using UnityEngine.Input

Occurs when legacy Input code (like Input.GetAxis or Input.GetKey) executes while Unity is configured for the modern Input System package only.

Quick 2-Step Solution

  1. Go to Edit → Project Settings → Player → Other Settings.
  2. Scroll down to Active Input Handling and change it from Input System Package (New) to Both.
  3. Unity will ask to restart the Editor. Click Apply.
1

Or Migrate to Modern Input System Code

ModernInputFix.cs (C#)
using UnityEngine;
using UnityEngine.InputSystem; // Add this namespace!

public class ModernInputFix : MonoBehaviour
{
    private void Update()
    {
        // ❌ OLD LEGACY CODE (Causes InvalidOperationException):
        // float h = Input.GetAxis("Horizontal");

        // ✅ MODERN INPUT SYSTEM REPLACEMENT:
        float h = 0f;
        if (Keyboard.current != null)
        {
            if (Keyboard.current.dKey.isPressed) h += 1f;
            if (Keyboard.current.aKey.isPressed) h -= 1f;
        }

        if (Gamepad.current != null)
        {
            h = Gamepad.current.leftStick.x.ReadValue();
        }
    }
}

Learn the Modern Input System