Move scripts under Assets/Scripts/ into Components, GameMode, Helper, Network, Enum, Struct and ScriptableObject folders. Pure file moves (plus folder .meta files); no code changes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
23 lines
978 B
C#
23 lines
978 B
C#
using Unity.Netcode;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
[DisallowMultipleComponent]
|
|
public class SpectatorSetup : NetworkBehaviour
|
|
{
|
|
public override void OnNetworkSpawn()
|
|
{
|
|
if (!IsOwner) return;
|
|
|
|
var manager = FindFirstObjectByType<GameModeManager>(FindObjectsInactive.Include);
|
|
if (manager) manager.BindSpectator();
|
|
}
|
|
}
|