M1: fix PlayerDriver input for New-only Input System (Keyboard.current)
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) <noreply@anthropic.com>
This commit is contained in:
parent
251ac8acec
commit
78f16f6a22
1 changed files with 13 additions and 6 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue