using System.Collections; using System.Collections.Generic; using UnityEngine; using Mirror; using StarterAssets; using Player; public class ComponentsSync : NetworkBehaviour { public List objects; public List scripts; public SkinnedMeshRenderer playerModel; public Interactions interactions; public CharacterController controller; // public SpectatorController specController; public PersonController persController; public bool alive = true; void Start() { persController.OnLiveState += OnLiveState; if (!isLocalPlayer) { foreach (var gameObject in objects) { gameObject.SetActive(false); } foreach (var script in scripts) { script.enabled = false; } } else { playerModel.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly; alive = persController.Alive; } } private void OnLiveState(Pawn player, bool state) { alive = state; if (isLocalPlayer) { interactions.enabled = alive; controller.enabled = alive; // specController.enabled = alive; } else { if (alive) { playerModel.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On; } else { playerModel.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly; } } } }