Making a remote procedure call return a value from the serve

As far as I know, a RPC cannot be made to return a value due to the complexities involved with network lag.

To that end, we have to use 2 RPCs,

one from the client to initiate a server request
one from the server to initiate a client response

How do we make sure the RPC goes back to the appropriate client? - there is no RPCMode.Client (nor could such a command exist).

How would you make sure the message gets back to where the initial RPC originated from?

One way I can think of is by adding a networkplayer parameter to the original RPC but then the response from the server would go to all clients with only one knowing to actually respond to the RPC.

Sincerely confused, would appreciate any help.

Kind regards

there is such a mode: instead of rpcmode you just specify the networkplayer you want to send to

see 2nd half of the .RPC docs :slight_smile:

And as per the RPC docs (near the bottom of the following page) you can see how to use the NetworkMessageInfo parameter which will give you the player that sent the RPC.

http://unity3d.com/support/documentation/Components/net-RPCDetails.html