get return on networkView.RPC


I have following line of code:


So my problem with that line is, that I need to get an answer from the server whether or not the username is already used by another player. But I don’t know how I could send the message from the server back to the client. As I only want this one client to get the answer not all clients.

You just need to check the NetworkMessageInfo.sender attribute sent automatically with the RPC :

from the docs:

function PrintText (text : String, info : NetworkMessageInfo)
    Debug.Log(text + " from " + info.sender);

AFAIK there is no RPCMode that lets you send to a single specific player (why not? dunno…) but you can use RPCMode.Others and have it just do nothing if the sent network player id does not match the local player’s.

But I’m not sure about your idea of using a Unity game server to register / keep track of in-use usernames in the first place, I would use (actually, am using) a WWWForm connecting to a PHP script connecting to an SQL database.