using Unity.Netcode; using UnityEngine; /// /// Per-avatar glue for a mid-match SPECTATOR. The spectator object is deliberately empty (no body, /// renderer, collider or controller) - the free-fly camera is a separate, persistent scene object in /// Main, so this only has to exist as the owner's player object and flip the local mode set to /// free-cam-only; remote peers do nothing. MatchManager respawns it as a lobby Player at match end. /// [DisallowMultipleComponent] public class SpectatorSetup : NetworkBehaviour { public override void OnNetworkSpawn() { if (!IsOwner) return; var manager = FindFirstObjectByType(FindObjectsInactive.Include); if (manager) manager.BindSpectator(); } }