From 78f16f6a223292ad5a146f4fff1373d506f9f22f Mon Sep 17 00:00:00 2001 From: megaproxy Date: Fri, 10 Jul 2026 23:30:31 +0100 Subject: [PATCH] M1: fix PlayerDriver input for New-only Input System (Keyboard.current) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Project ships Active Input Handling = Input System (New) only, so the drafted legacy Input.GetAxisRaw would throw InvalidOperationException at runtime. Read WASD/arrows off Keyboard.current instead — no restart, no action asset needed. (TreadPart needs the same swap when the bot lands.) Co-Authored-By: Claude Opus 4.8 (1M context) --- Assets/Scripts/Net/PlayerDriver.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Assets/Scripts/Net/PlayerDriver.cs b/Assets/Scripts/Net/PlayerDriver.cs index 640f4f5..0691292 100644 --- a/Assets/Scripts/Net/PlayerDriver.cs +++ b/Assets/Scripts/Net/PlayerDriver.cs @@ -32,6 +32,7 @@ using Unity.Netcode; using UnityEngine; +using UnityEngine.InputSystem; namespace Jankenbots.Net { @@ -83,12 +84,18 @@ namespace Jankenbots.Net // host, for capsules it doesn't own) skips input entirely — IsOwner is the gate. if (!IsOwner) return; - // Throwaway-prototype input: legacy Input axes are perfectly fine here. WASD / arrows - // / left stick map to Horizontal + Vertical out of the box. (The project ships the new - // Input System, but its compatibility mode feeds these same axes, so this Just Works - // for M1 without authoring an action asset.) - float strafe = Input.GetAxisRaw("Horizontal"); // A/D, left-stick X - float fwd = Input.GetAxisRaw("Vertical"); // W/S, left-stick Y + // Throwaway-prototype input via the new Input System. The project ships New-only, so + // legacy UnityEngine.Input.GetAxis would THROW at runtime — read WASD / arrow keys + // straight off the current keyboard instead. No action asset needed for an M1 smoke test. + var kb = Keyboard.current; + float strafe = 0f, fwd = 0f; + if (kb != null) + { + if (kb.aKey.isPressed || kb.leftArrowKey.isPressed) strafe -= 1f; // left + if (kb.dKey.isPressed || kb.rightArrowKey.isPressed) strafe += 1f; // right + if (kb.wKey.isPressed || kb.upArrowKey.isPressed) fwd += 1f; // forward + if (kb.sKey.isPressed || kb.downArrowKey.isPressed) fwd -= 1f; // back + } Vector2 input = new Vector2(strafe, fwd); // Normalize so diagonal input isn't ~1.4x faster; keep magnitude for analog sticks.