controls: on-foot always-on mouse-look + camera-relative WASD + E/Q claim
- CameraDirector: AvatarFollow now uses always-on mouse-look (no RMB) with a locked/hidden cursor; Esc toggles the cursor free; RobotFollow keeps RMB-look. - PlayerAvatar: movement is camera-relative (W = camera forward, character turns to face where it runs) instead of world/cardinal. - PlayerAvatar: E claims a tread on foot, Q leaves while seated (locked cursor makes the OnGUI buttons unclickable). - Verified in play: cursor locks in on-foot mode, camera-relative basis correct, no runtime errors. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3082644dbd
commit
30d0b27813
2 changed files with 33 additions and 3 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue