using Unity.Netcode; using UnityEngine; /// /// Per-avatar network glue on the spawned player. The local owner binds the scene singletons /// (GameModeManager, cameras) to itself via ; remote /// avatars stop simulating so their transform is driven purely by the NetworkTransform replication. /// Position-sync milestone: remote avatars still show their mesh/idle pose, just no local control. /// [RequireComponent(typeof(PlayerCharacterController))] [DisallowMultipleComponent] public class NetworkPlayerSetup : NetworkBehaviour { public override void OnNetworkSpawn() { var controller = GetComponent(); if (IsOwner) { var manager = FindFirstObjectByType(FindObjectsInactive.Include); if (manager) manager.BindLocalPlayer(controller); return; } // Remote avatar: NetworkTransform owns the transform here, so disable the local // simulation (input/movement) and the CharacterController's own depenetration. if (controller) controller.enabled = false; var cc = GetComponent(); if (cc) cc.enabled = false; } }