Photon Fusion RPC Problem

Hello,

I am currently making a multiplayer RTS demo using Photon Fusion in Host Mode where each player(client) has input authority over his own units. i want to send an RPC from the host to a client for a unit that the host does not own. Then I want to send an RPC from that client back to the host version of that unit. The following first 2 RPCs work, but the last RPC that should show a message on the host, does not work. I don’t get any errors either. Cany anyone tell me what I am doing wrong?
Thanks in advance!

      //Called on unit that the host does not own
      [Rpc(RpcSources.All, RpcTargets.StateAuthority)]//Send from host to server
      void RPC_Test()
      {
          RPC_Test2();
      }
         
        //Executed on unit belonging to target client
        [Rpc(RpcSources.StateAuthority, RpcTargets.InputAuthority)]
        void RPC_Test2()
        {
            Debug.Log("Executing Test 2");
            RPC_Test3();
        }
      
       //Send from target client back to server(This does not work, but I don't get any error either)
       [Rpc(RpcSources.InputAuthority, RpcTargets.StateAuthority)]
        void RPC_Test3()
        {
            Debug.Log("Executing Test 3");
        }

If I read the RPC parameters correctly, the RPC_Test3 can only be called from the “input authority” respectively it gets sent only to “state authorities”. So check if that is the case for both ends.

That’s an odd comment because the host is the server.

Hello,

Yes I checked that the target client who owns the unit in question has input authority over it. That is why I expected the target client to send back a message to the host/server via RPC_Test3().

The method calling RPC_Test() looks like this:

public void Test()
{
    if(!HasInputAuthority)
    {
        RPC_Test();
    }
}

I finally solved the problem. For some reasons I had to wait a short time before calling the last rpc.
So this is how my solution looks now:

       void Test()
       {
           if(!HasInputAuthority)
           {
                 RPC_Test();
           }
        }

        [Rpc(RpcSources.All, RpcTargets.StateAuthority)]
        void RPC_Test()
        {
            RPC_Test2();
        }

        [Rpc(RpcSources.StateAuthority, RpcTargets.InputAuthority)]
        void RPC_Test2()
        {
            Debug.Log("Executing Test 2");
            StartCoroutine(DelayedTest3());
        }

        IEnumerator DelayedTest3()
        {
            yield return new WaitForSeconds(0.1f);
            RPC_Test3();
        }
       
        [Rpc(RpcSources.InputAuthority, RpcTargets.StateAuthority)]
        void RPC_Test3()
        {
            Debug.Log("Executing Test3");
        }


That’s not a solution, it’s a hack!

Perhaps the execution of the RPC here depends on latency, in that case waiting for 0.1 may work for you locally but may still fail for a percentage of users with higher latency.

Try to find out WHY this delay seems necessary. Definitely try with the most unrestricted Rpc attributes.

Hi, I had exactly the same problem like yours, and I solved it by adding a 0.1s delay before calling the RPC(client send back to host). But I think this is a trick. May I ask do you know the real problem causes the bug now?

1 Like