Files
chameleon/Assets/Scripts/FreeCamMode.cs
T
adminandClaude Opus 4.8 a3ef7055b4 Add free-camera mode with player-equivalent collision
Introduce a free-fly camera as the next entry in the Tab mode cycle
(Player Control -> Paint -> Free Cam):

- FreeCamController: dedicated CinemachineCamera plus a CharacterController
  mirroring the player capsule (radius 0.1, height 1.3, slope 59, step 0.15)
  so the free camera collides with walls/ceiling/floor exactly like the
  player. WASD/Q-E (and Space/Ctrl) fly relative to view; mouse looks.
- FreeCamMode: plain-C# GameMode mirroring PaintMode, with an Exit() that
  restores camera priority and re-enables player control + camera input.
- GameModeManager: register freeCam in the Tab cycle (gated like player).
- Scene: FreeCamera object wired, Main Camera custom blends (0.4s) for the
  vcam priority hand-off.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 23:01:14 +02:00

42 lines
1.5 KiB
C#

/// <summary>
/// Free-fly camera mode. The player is frozen in place, painting is off, and a dedicated
/// freecam (<see cref="FreeCamController"/> + its own CinemachineCamera) takes over: fly the
/// camera through the map with WASD/Q/E and the mouse, colliding with world geometry like the
/// player. The orbit camera input is disabled while here so it doesn't fight for the cursor.
/// </summary>
public class FreeCamMode : GameMode
{
public override string DisplayName => "Free Cam";
public override void Enter()
{
// Keep the player component alive (gravity/grounding) but reject input, like Paint mode.
if (Manager.Player)
{
Manager.Player.enabled = true;
Manager.Player.ControlEnabled = false;
}
if (Manager.Painter)
Manager.Painter.PaintingEnabled = false;
// The orbit rig would otherwise keep grabbing the cursor and reading the mouse every frame.
if (Manager.CameraInput)
Manager.CameraInput.enabled = false;
if (Manager.FreeCam)
Manager.FreeCam.SetActive(true);
}
public override void Exit()
{
// Modes are Enter-only, so freecam must undo its own camera takeover here; the next mode's
// Enter restores the player/painter/look-mode state.
if (Manager.FreeCam)
Manager.FreeCam.SetActive(false);
if (Manager.CameraInput)
Manager.CameraInput.enabled = true;
}
}