Responding to a specific client from the server

I’m converting one of my projects to UNet to see how it works. One issue I’ve encountered is that I can’t see an obvious way to send data from the server to a specific client.

I want to request world data from the server. Under the old system I would have had some sort of centralised world controller on clients to RPC back and forth this sort of data, but now it seems clients only communicate with the server through their player object by commands. That’s workable (though it seems a bit untidy), but then on the server my only option seems to be a clientRPC which will actually send data to each version of the player, rather than just the specific player/client who made the request.

I have had a vague look at UNet messages, is that where I should be handling this sort of thing?

Thanks :slight_smile:

Hi !

Yes ! You have to create a network message and send it to a specific player.
For now there is no way to specify a connection id with a RPC.

The documentation for the network message:
http://docs.unity3d.com/Manual/UNetMessages.html

The function to use to send the message:
http://docs.unity3d.com/ScriptReference/Networking.NetworkServer.SendToClient.html

1 Like