[PHOTON] Can't destroy network object that created by other player even if MasterClient

I’m making object sync in my game, and noticed that i can’t destroy object that was created by other player using PhotonNetwork.Destroy(object); even if MasterClient

I’m sharing my code and hope that Photon staff will help me to solve it.

                if (photonView.IsMine && PhotonNetwork.InRoom)
                {
                    var objectView = collider.GetComponent<PhotonView>();
                    if (objectView.Owner == photonView.Owner)
                    {
                        PhotonNetwork.Destroy(object);
                    }
                    else
                    {
                        photonView.RPC("MP_Destroy", RpcTarget.MasterClient, photonView.ViewID, objectView.ViewID);
                    }
                }

RPC Code:

    [PunRPC]
    public void MP_Destroy(int player_id, int viewID)
    {
        if (PhotonNetwork.IsMasterClient)
        {
            PhotonView objectPhotonView = PhotonView.Find(viewID);
            print("MP_Destroy You are host, object destroyed : " + viewID);
            GameObject obj = objectPhotonView.gameObject;
            if (obj != null)
            {
                PhotonNetwork.Destroy(obj);
            }
        }

    }

Error:
Failed to ‘network-remove’ GameObject. Client is neither owner nor MasterClient taking over for owner who left: View 2003 on “object”

Other Info:

  • Master ID: 1001
  • Client ID that sent RPC: 1001 (master)
  • Object ID: 2003
  • Object owner ID: 2001
  • Owner is still on the scene (he is not left)

MasterClient is received the RPC call, but output the Error above.
Probably i’m just confused, but it should work this way!
What i’m doing wrong here?

I am basically as puzzled as you are. Why is object 2003 involved here? Is that the “collider”?
Maybe that is where things are mixed up.
You want to call the RPC on the networked object you target (and which is the one that should get destroyed). That’s enough to actually “target” it, because RPCs are executing the script on the object related to the PhotonView.

Yes, it’s an collider. But what i want to say, that this collider was created by other player (2001).
The idea is that each player can create some objects, and any other player can interact with these objects.

So what i have tried in first post is:

  1. player with ID 2001 created an object that have PhotonView = 2003 (because it’s not first created object by this player)
  2. other player, which is master server in this case, trying to send RPC to MasterServer (literally to himself).
  3. error.

se (pv.IsMine)
{
PhotonNetwork.Destroy(este.objeto_de_jogo);
}
outro
{
Destruir(this.gameObject);
}