using Kryz.CharacterStats.Examples; using Photon.Pun; using System.Collections; using System.Collections.Generic; using UnityEngine; public class RiftPlayer : MonoBehaviour { [Header("Class:")] public GameTag classTag; [Header("Events:")] [SerializeField] private GameEvent_PhotonView onPlayerSpawned; [SerializeField] private GameEvent_Player onPlayerDeath; [HideInInspector] public PhotonView photonView; [HideInInspector] public PlayerCharacterStats character; public Transform projectileSpawnLocation; [HideInInspector] public Health health; PlayerDeathManager playerDeathManager; private void Awake() { photonView = GetComponent(); character = GetComponent(); health = GetComponent(); playerDeathManager = GetComponentInChildren(); health.onDeath.AddListener(OnDeath); } // Start is called before the first frame update void Start() { this.photonView.Owner.TagObject = this; onPlayerSpawned.Raise(this.photonView); this.gameObject.name = photonView.Owner.NickName; } private void OnDeath() { if (!photonView.IsMine) return; photonView.RPC(nameof(RPC_OnDeath), RpcTarget.All); } [PunRPC] private void RPC_OnDeath() { onPlayerDeath.Raise(photonView.Owner); } }