using Unity.Netcode; using UnityEngine; /// /// Per-avatar glue for a mid-match SPECTATOR. The spectator object is deliberately empty - no body, no /// renderer, no collider, no controller - because the free-fly camera is a separate, persistent scene /// object (in Main) that drives its own rig off Camera.main and needs nothing from this avatar. So the /// spectator only has to exist as the owner's player object and flip the local mode set to free-cam-only. /// The owner does that here; remote peers do nothing (there is no body to show or simulate). When the /// host ends the match, MatchManager respawns this client as a neutral lobby Player. /// [DisallowMultipleComponent] public class SpectatorSetup : NetworkBehaviour { public override void OnNetworkSpawn() { if (!IsOwner) return; var manager = FindFirstObjectByType(FindObjectsInactive.Include); if (manager) manager.BindSpectator(); } }