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>
This commit is contained in:
1 parent
0edc59555a
commit
a3ef7055b4
10 files changed
+472
-19
No files matched your search
@@ -5,7 +5,7 @@ using UnityEngine.InputSystem;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Switches the game between high-level modes (Player Control, Paint). The switch
|
||||
/// Switches the game between high-level modes (Player Control, Paint, Free Cam). The switch
|
||||
/// key (Tab) cycles to the next registered mode. Register additional modes in
|
||||
/// <see cref="BuildModes"/>. Attach to a single, persistent scene GameObject.
|
||||
/// </summary>
|
||||
@@ -22,6 +22,9 @@ public class GameModeManager : MonoBehaviour
|
||||
[Tooltip("Mesh painter. Empty = found automatically.")]
|
||||
public MeshPainter painter;
|
||||
|
||||
[Tooltip("Free-fly spectator camera. Empty = found automatically. Absent = Free Cam is left out of the cycle.")]
|
||||
public FreeCamController freeCam;
|
||||
|
||||
//[Tooltip("Insect / surface-walk controller. Empty = found automatically.")]
|
||||
//public InsectController insect;
|
||||
|
||||
@@ -39,6 +42,7 @@ public class GameModeManager : MonoBehaviour
|
||||
public PlayerCharacterController Player => player;
|
||||
public ThirdPersonOrbitInput CameraInput => cameraInput;
|
||||
public MeshPainter Painter => painter;
|
||||
public FreeCamController FreeCam => freeCam;
|
||||
//public InsectController Insect => insect;
|
||||
|
||||
/// <summary>Raised after a mode switch finishes (the new mode's Enter has already run).
|
||||
@@ -57,6 +61,8 @@ public class GameModeManager : MonoBehaviour
|
||||
if (!player) player = FindFirstObjectByType<PlayerCharacterController>();
|
||||
if (!cameraInput) cameraInput = FindFirstObjectByType<ThirdPersonOrbitInput>();
|
||||
if (!painter) painter = FindFirstObjectByType<MeshPainter>();
|
||||
// Include inactive so a freecam rig that starts disabled is still found and wired.
|
||||
if (!freeCam) freeCam = FindFirstObjectByType<FreeCamController>(FindObjectsInactive.Include);
|
||||
//if (!insect) insect = FindFirstObjectByType<InsectController>();
|
||||
|
||||
BuildModes();
|
||||
@@ -80,6 +86,10 @@ public class GameModeManager : MonoBehaviour
|
||||
|
||||
_modes.Add(new PaintMode());
|
||||
|
||||
// Free Cam only joins the cycle when a freecam rig is present, so scenes without one are unchanged.
|
||||
if (freeCam)
|
||||
_modes.Add(new FreeCamMode());
|
||||
|
||||
// Insect mode only joins the Tab cycle when a surface walker is present, so a scene
|
||||
// without one behaves exactly as before (no dead, player-freezing mode in the cycle).
|
||||
//if (insect)
|
||||
|
||||
Reference in new issue
Block a user