RPC issue, Scene Object Not applying RPC!

Options
Hello
I am currently working on a survival game using Photon. I recently made a script to handle the trees in the scene, Each tree has it's own photon view and treeHealth script. However when a player hits the tree and sends an ApplyDamage RPC to the tree and destroys the tree. Other players joining later will receive the ApplyDamage RPC and the disable tree RPC, but the tree is still showing on the clients screen. I really need some help with this issue. Thank you! I have posted my code below for the TreeHealth.

using UnityEngine; using System.Collections; using CodeStage.AntiCheat.ObscuredTypes; using Photon; public class TreeHealth : Photon.MonoBehaviour { //Other components// public PhotonView pv; public Collider TreeCollider; public Renderer TreeRenderer; //Obscured floats// public float TreeHP; public float RespawnTimer = 600; //Obscured bools// public bool StartRespawnTimer = false; public bool TreeDisable = false; // Use this for initialization void Start() { pv = this.gameObject.GetComponent<PhotonView>(); TreeCollider = this.gameObject.GetComponent<CapsuleCollider>(); TreeRenderer = this.gameObject.GetComponent<MeshRenderer>(); } // Update is called once per frame void Update() { if (StartRespawnTimer) { RespawnTimer -= Time.deltaTime; } if (RespawnTimer <= 0) { //pv.RPC("EnableTree", PhotonTargets.AllBuffered, null); if (PhotonNetwork.isMasterClient) { pv.RPC("EnableTree", PhotonTargets.AllBufferedViaServer, null); } } if (PhotonNetwork.isMasterClient) { if (TreeDisable == false) { if (TreeHP <= 0) { pv.RPC("DisableTree", PhotonTargets.AllBuffered, null); StartRespawnTimer = true; } } } } [PunRPC] public void ApplyDamage() { TreeHP -= 50f; Debug.Log("Tree took damage"); } [PunRPC] public void DisableTree() { TreeRenderer.enabled = false; TreeCollider.enabled = false; TreeDisable = true; Debug.Log("tree is disabled"); } [PunRPC] public void EnableTree() { StartRespawnTimer = false; TreeCollider.enabled = true; TreeRenderer.enabled = true; RespawnTimer = 600; TreeDisable = false; TreeHP = 100; Debug.Log("tree is enabled"); } }

Comments

  • vadim
    Options
    Hi,

    This may be because of timer you use. All buffered RPCs arrive to new joined client at join time. I'm not sure that your timer supports such scenario.