PhotonView with ID x has no method "MethodName"

Options
Sorry for the basic question. I can't quite seem to grasp RPCs.

What is happening currently:

I have a GameObject called "Wrench", with a PhotonView, and a script InventoryItem.cs. Within InventoryItem is an RPC:

[code2=csharp][RPC]
public void PickUp(GameObject player) {
Debug.Log("Is this thing on?");
//irrelevant stuff
}[/code2]

There is a CirclePicker UI element that is a child of the wrench. The CirclePicker has its own child, a CirclePickerButton. When clicked, the CirclePickerButton executes the following code:

[code2=csharp]PhotonView objectPhotonView = PhotonView.Get(transform.parent.parent.parent); // yes, I know this is horrible code!!
objectPhotonView.RPC("PickUp", PhotonTargets.All);[/code2]

Yet whenever I click on the button, I get an error:

[code2=csharp]PhotonView with ID 1 has no method "PickUp" that takes 0 argument(s):
UnityEngine.Debug:LogError(Object)
NetworkingPeer:ExecuteRPC(Hashtable, PhotonPlayer) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2194)
NetworkingPeer:RPC(PhotonView, String, PhotonTargets, Boolean, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2955)
PhotonNetwork:RPC(PhotonView, String, PhotonTargets, Boolean, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:2496)
PhotonView:RpcSecure(String, PhotonTargets, Boolean, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:589)
PhotonView:RPC(String, PhotonTargets, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:557)
CirclePickerButtonManager:DoAction() (at Assets/_MY ASSETS/Scripts/CirclePickerButtonManager.cs:36)
UnityEngine.EventSystems.EventSystem:Update()[/code2]

What am I doing wrong here? Do RPCs have to be called within the script they live in? Even if the method is defined as public?

Cheers!

Comments

  • vadim
    Options
    'PickUp' RPC method defined as accepting single parameter but you call it w/o any parameters at all.
    To fix that, remove 'GameObject player' from method definition (you can't send GameObject's over network anyway).
    If you need additional info on RPC call, add last PhotonMessageInfo parameter (single in your case) to RPC method parameters list.
  • vadim wrote:
    'PickUp' RPC method defined as accepting single parameter but you call it w/o any parameters at all.
    To fix that, remove 'GameObject player' from method definition (you can't send GameObject's over network anyway).
    If you need additional info on RPC call, add last PhotonMessageInfo parameter (single in your case) to RPC method parameters list.

    How could I miss that! Thanks very much for your help.