The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

RPC problem with PhotonViews

2019-09-02 00:28:27

When I send an RPC, simply, the only object that receives it is the SAME PHOTONVIEW that SENT IT but in every instance. Here's the code, just for debugging.

void Update(){  

if (Input.GetKeyDown(KeyCode.F) && timerPush >= cdPush)  
                timerPush = 0;  
                Debug.Log("PULSANDO F");  

 void Push()  
           this.photonView.RPC("PushBack", RpcTarget.Others);  

    void PushBack(PhotonMessageInfo info)  
            Debug.LogWarning("RPC RECEIVED BY " + this.photonView.ViewID + " THAT CORRESPONDS TO " +   
            this.photonView.Owner.NickName + " that was sent by " + info.photonView.Owner.NickName + " with ID "+   
        if (this.photonView.IsMine && info.photonView.ViewID != this.photonView.ViewID)  

            gameObject.transform.position = new Vector3(0, 0, -1.2f);  

I also get this error that I dont know what it means.

NullReferenceException: Object reference not set to an instance of an object  
Photon.Pun.PhotonNetwork.ExecuteRpc (ExitGames.Client.Photon.Hashtable rpcData, Photon.Realtime.Player sender) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:506)  
Photon.Pun.PhotonNetwork.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:1997)  
Photon.Realtime.LoadBalancingClient.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2782)  
ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PeerBase.cs:640)  
ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:544)  
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1535)  
Photon.Pun.PhotonHandler.FixedUpdate () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:116)  

I guess it "cant see" the others photonView... I just don't know. I'm stuck at this point for 2 whole days doing debug but I can't find anything.


2019-09-02 09:33:06

Hi @ImNightm4re,

Thank you for choosing Photon!

  • Make sure the component that has the RPC method is attached to the same GameObject as the one that has the PhotonView, not its child nor its parent.
  • Make sure there is no other "PushBack" method with different signature in there.
  • Make sure the "PushBack" method is not static.
  • Make sure there is only one instance of the component that has the RPC method attached to the GameObject.

2019-09-02 09:58:42

Thank you for the response!

  1. Yes, it's in the same GameObject
  2. No, there isn't.
  3. No, it's not static.
  4. Yes, there's just one.

When I start the game, it'd look like this:

In each instance of the game I have 2 GameObjects -> Player 1 and Player 2. Each one with a different PhotonView ID, one controlled locally and the other isn't. Each GameObject has "PlayerMovement" script where the RPC is.

2019-09-02 16:08:59

Hey @ImNightm4re,

What PUN version are you using?
In PhotonServerSettings do you see the RPC "PushBack" in the RPCs shortcuts list from the inspector in the Unity Editor?

2019-09-03 22:31:48

Sorry for the late response but I wasn't at home. My Photon version is 2.13 and yes, I do see "PushBack" in RPCs list.

2019-09-03 23:32:05

Just updated to 2.14*

2019-09-05 01:05:44

Maybe that helps. When I add another argument to the RPC like "int wtf", I get the following message instead.

PhotonView with ID 2001 has no method "PushBack" that takes 1 argument(s): Int32  
Photon.Pun.PhotonNetwork:ExecuteRpc(Hashtable, Player) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:532)  
Photon.Pun.PhotonNetwork:OnEvent(EventData) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:1997)  
Photon.Realtime.LoadBalancingClient:OnEvent(EventData) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2752)  
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PeerBase.cs:640)  
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:552)  
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1548)  
Photon.Pun.PhotonHandler:Dispatch() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:193)  
Photon.Pun.PhotonHandler:FixedUpdate() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:127)

2019-09-05 09:55:11

Hi @ImNightm4re,

PUN can't find the "PushBack" RPC method on the receiving end.
It looks like "PlayerMovement" is not attached to the same GameObject as the PhotonView.

The NullReferenceException will be fixed in the next PUN2 update, basically, it's an exception in the code that tells you that there is no suitable method for the received RPC.

If you still have issues with this, send us a minimal repro project at [email protected].

2019-09-14 13:23:02

Ok, so I had 2 scripts "PlayerMovement" attached to the gameObject and that seems to have been causing the error... Thank you and sorry about that post o:) .

Back to top