diff --git a/Assets/Scripts/Camera/CameraDirector.cs b/Assets/Scripts/Camera/CameraDirector.cs index c30d6f2..770120d 100644 --- a/Assets/Scripts/Camera/CameraDirector.cs +++ b/Assets/Scripts/Camera/CameraDirector.cs @@ -61,6 +61,7 @@ namespace Jankenbots.Prototype float _pitch = 18f; float _dist = 8f; float _cineAngle; + bool _cursorFree; // Esc toggles the locked cursor free (for GUI / to escape play) PlayerAvatar _local; @@ -115,13 +116,21 @@ namespace Jankenbots.Prototype if (want != _mode) { _mode = want; Apply(_mode); } } - // Look / zoom input — only for the orbitable follow cams. + // Cursor + look. On-foot (AvatarFollow) uses ALWAYS-ON mouse-look with a + // locked cursor (no RMB needed); other modes keep the cursor free (RobotFollow + // orbits while RMB is held). Esc toggles the cursor free to reach GUI / escape. + if (kb != null && kb.escapeKey.wasPressedThisFrame) _cursorFree = !_cursorFree; + bool avatarLook = _mode == Mode.AvatarFollow && !_cursorFree; + Cursor.lockState = avatarLook ? CursorLockMode.Locked : CursorLockMode.None; + Cursor.visible = !avatarLook; + if (_mode == Mode.AvatarFollow || _mode == Mode.RobotFollow) { var m = Mouse.current; if (m != null) { - if (m.rightButton.isPressed) + bool look = _mode == Mode.AvatarFollow ? avatarLook : m.rightButton.isPressed; + if (look) { Vector2 d = m.delta.ReadValue(); _yaw += d.x * lookSensitivity; diff --git a/Assets/Scripts/Player/PlayerAvatar.cs b/Assets/Scripts/Player/PlayerAvatar.cs index 097acd6..97a22fa 100644 --- a/Assets/Scripts/Player/PlayerAvatar.cs +++ b/Assets/Scripts/Player/PlayerAvatar.cs @@ -104,6 +104,15 @@ namespace Jankenbots.Prototype else ExitSeated(); } + // Claim / leave a tread by KEY. On-foot mouse-look locks the cursor, so + // the OnGUI Claim/Leave buttons aren't clickable — E claims, Q leaves. + var kb = Keyboard.current; + if (_seats != null && kb != null) + { + if (!_seated && kb.eKey.wasPressedThisFrame) _seats.ClaimSeatRpc(); + else if (_seated && kb.qKey.wasPressedThisFrame) _seats.ReleaseSeatRpc(); + } + // On foot → drive the avatar. Seated → do nothing (control is on the tread). if (!_seated) OwnerMove(); } @@ -169,7 +178,19 @@ namespace Jankenbots.Prototype if (kb.sKey.isPressed || kb.downArrowKey.isPressed) v -= 1f; } - Vector3 input = new Vector3(h, 0f, v); + // CAMERA-RELATIVE movement: W goes the way the camera (mouse) is looking, + // not world +Z. Basis is the active game camera flattened onto the ground. + Vector3 camF = Vector3.forward, camR = Vector3.right; + var cam = Camera.main; + if (cam != null) + { + camF = Vector3.ProjectOnPlane(cam.transform.forward, Vector3.up); + if (camF.sqrMagnitude < 1e-4f) camF = Vector3.ProjectOnPlane(cam.transform.up, Vector3.up); // looking straight down + camF.Normalize(); + camR = Vector3.ProjectOnPlane(cam.transform.right, Vector3.up).normalized; + } + + Vector3 input = camR * h + camF * v; if (input.sqrMagnitude > 1f) input.Normalize(); Vector3 desired = input * moveSpeed;