Failed to 'network-remove' GameObject. C#

Options
I have two issues that I believe are related, in that they work for me locally, but when I try running another version of the game, I get these errors that seem to have to do with ownership of an object. First:

I'm trying to call:
PhotonNetwork.Destroy(pumpkin);

But I get this error when trying to destroy:
Failed to 'network-remove' GameObject. Client is neither owner nor masterClient taking over for owner who left: View (0)2007 on Pumpkin(Clone)

Another issue I am having is with RPC calls. I'm trying to call:
photonView.RPC("SetAnimLayer", PhotonTargets.All, 10);

But I get the error:
PhotonView with ID 1005 has no method "SetAnimLayer" marked with the [RPC](C#) or @RPC(JS) property! Args: Int32
UnityEngine.Debug:LogError(Object)

Even though my RPC function is being called like this:
[RPC]
	public void SetAnimLayer(int anLayer){
		print ("Change to Layer: " + anLayer);
	}

I'm curious to know if these two things are related, and what I am doing wrong as the errors do not happen when reproduced in the built in unity networking.

Just out of curiosity, I'm wondering if my issue may have to do with "Changing the PUN source code" as Tobias from Exit Games mentioned in this short post.
viewtopic.php?f=6&t=3949

Thank you for your help, and please let me know if you need any further explanation.

Comments

  • vadim
    Options
    Errors describe reasons pretty clearly

    First error states that you are trying to destroy object on client other than that created the object (owner). If you want initiate destroy on other client, send 'RPC to owner and destroy object in RPC handler.

    Second error is because of photonView.RPC() is called for object that has no SetAnimLayer method in attached Photon.MonoBehaviour.
  • I understand what you're saying about the destroy issue, and that I need to send an RPC to do it from the owner. The issue is that the RPC function is in the same script as the RPC function and, by that nature, on the same object. I'm not sure why that doesn't work.
  • vadim
    Options
    Your code looks ok. Probably error in some other parts (proper call or PhotonView assign). I can't guess. Can you check your RPC against any demo with RPC such as Tutorial_2A3? If demo works for you, what is the difference?
  • I gave it a shot and it works in the Tutorial_2A3, but it still does not work in my script. I can include more code if it would help, but I'm at a loss as to why it's not working from identical points in the scripts.
  • vadim
    Options
    Can you send me a minimal test that does not work for you? No app details, just essentials as in Tutorial_2A3