HELP WITH BUFFERED RPC'S and SCENE OBJECTS!

Options
Hello!
I am having trouble have bufferd RPC's send to clients that join the game late. I want to pick up a rock that is already in the scene. It has a photon view and the master and clients that are in the game already can pick up the object and have it destroyed for all other clients in the game already. Like I said before the problem I am having is that when other clients join the game after that object has already been destroyed, it is still there for them and they can not do anything with it.
Here is my code for the pickup and the code that is attached to the object.

Pickup C#
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class Pickup : MonoBehaviour {

//Ohter Scripts//
public PhotonView pv;


public Ray ray;
public RaycastHit Rayhit;

public float Raylength = 10;



//UI Stuff//
public Text PickupText;


// Use this for initialization
void Start ()
{
pv = this.gameObject.GetComponent ();

PickupText = GameObject.FindWithTag ("Pickup Text").GetComponent ();
}

// Update is called once per frame
void Update ()
{

ray = Camera.main.ScreenPointToRay (Input.mousePosition);


if (Physics.Raycast (ray, out Rayhit, Raylength)) {

if (Rayhit.collider.gameObject.tag == "Stone") {
PickupText.enabled = true;

if (Input.GetKeyDown (KeyCode.F)) {
Rayhit.collider.gameObject.GetComponent().RPC("PickUpStone", PhotonTargets.AllBufferedViaServer);
InventorySystem.stone += 1;
PickupText.enabled = false;
}
} else {

PickupText.enabled = false;
}




}
}


}




Object Script:
using UnityEngine;
using System.Collections;

public class PickUpObject : Photon.MonoBehaviour {





[PunRPC]
void PickUpStone()
{
PhotonNetwork.Destroy (this.gameObject);
}
}


Comments

  • You need to call PhotonNetwork.Destroy only once on client owning the object (master for scene objects). If non-owner client detected conditions for destroy, let him send RPC to owner only asking for destroy. Of course no need to cache such RPCs.