How to implement Photon to connect Playfab Multiplayer Server?

Options

I divided my Unity project to two. ServerScripts and ClientScripts.

ClientScripts will call ServerScripts which is deployed on Playfab Multiplayer Services.

However when i call below code, nothing happens.

What do i miss? How should i integrate photon to MPS?

photonView.RPC("SetUserData", RpcTarget.AllViaServer);


Best Answer

  • Tobias
    Tobias admin
    Answer ✓
    Options

    Nothing happens is quite a vague description. There must be some hints in the logs.

    You probably don't want to target AllViaServer. This will call the RPC on all clients while you only want to call it on a specific client (the one running ServerScripts).

    The problem may be that the RPC attempts to call the method SetUserData on the class ClientScripts. Not on the Class ServerScripts. So it won't find a target to call the method on.

    You may want to use RaiseEvent instead and get rid of the RPC workflow, which links these general calls to some specific NetworkedObject and class.

Answers

  • Tobias
    Tobias admin
    Answer ✓
    Options

    Nothing happens is quite a vague description. There must be some hints in the logs.

    You probably don't want to target AllViaServer. This will call the RPC on all clients while you only want to call it on a specific client (the one running ServerScripts).

    The problem may be that the RPC attempts to call the method SetUserData on the class ClientScripts. Not on the Class ServerScripts. So it won't find a target to call the method on.

    You may want to use RaiseEvent instead and get rid of the RPC workflow, which links these general calls to some specific NetworkedObject and class.