diff --git a/Assets/Scripts/Components/Controller/FreeCamController.cs b/Assets/Scripts/Components/Controller/FreeCamController.cs index 4e7e694..f57e525 100644 --- a/Assets/Scripts/Components/Controller/FreeCamController.cs +++ b/Assets/Scripts/Components/Controller/FreeCamController.cs @@ -60,7 +60,6 @@ public class FreeCamController : MonoBehaviour SmoothedLook _look; // yaw/pitch accumulator + smoothing shared with first person Vector3 _moveVelocity; // smoothed world-space flight velocity Vector3 _moveVelocityRef; - bool _ignoredPlayer; void Awake() { @@ -71,7 +70,10 @@ public class FreeCamController : MonoBehaviour else _vcam.Priority = inactivePriority; - // Dormant until FreeCamMode enters; nothing reads input or moves the rig meanwhile. + // Dormant until FreeCamMode enters: disable the capsule too, otherwise it lingers as a live + // collider sitting in the play area and blocks players who walk into it (a CharacterController + // stays a physics collider on its own, independent of this self-disabled script). + _controller.enabled = false; enabled = false; } @@ -82,6 +84,11 @@ public class FreeCamController : MonoBehaviour if (_vcam) _vcam.Priority = active ? activePriority : inactivePriority; + // Only a flying freecam needs its capsule; keep it out of the physics world otherwise so it + // never blocks players. Must be enabled before SyncToCurrentView, whose teleport preserves the + // current enabled state around the position write. + _controller.enabled = active; + if (active) { IgnorePlayerCollision(); @@ -141,14 +148,12 @@ public class FreeCamController : MonoBehaviour _moveVelocityRef = Vector3.zero; } - /// Stop the freecam capsule from being blocked by the (frozen) player's capsule. + /// Stop the freecam capsule from being blocked by the frozen players' capsules. Re-runs on + /// every activation on purpose: Physics.IgnoreCollision is reset when the freecam capsule is toggled + /// off/on, and the roster of live players can differ between spectate sessions. void IgnorePlayerCollision() { - if (_ignoredPlayer) return; - _ignoredPlayer = true; - - var player = FindFirstObjectByType(); - if (player) + foreach (var player in FindObjectsByType(FindObjectsSortMode.None)) { var playerCC = player.GetComponent(); // Only an enabled capsule can take part in a collision-ignore (a spectator's body has its CC