I'm trying to send an Rpc, or any sort of message, to a specific client instead of to them all.

I'm completely at the loss trying to associate a NetworkConnection with its own authoritative spawned player (from playerPrefab).

If I let the NetworkManager auto-spawn it, then I don't know how to get the connection from the player object.

If I override OnServerReady and I spawn it myself, then it has no authority on the client and I don't know how to give it.

I've browsed all sort of documentation but I couldn't find anything useful. Obviously there must be a way to do that, but I really can't find it.

  • \$\begingroup\$ I haven't worked in Unity before but couldn't you have the message include a user id when it's user specific and then only serve it to the user that matches? \$\endgroup\$ – Jade Aug 27 '15 at 21:55
  • \$\begingroup\$ @Jade "and then only serve it to the user that matches" that's what I'm asking. \$\endgroup\$ – o0'. Aug 28 '15 at 16:53
  • \$\begingroup\$ When a user logs in you keep track of their userID. Then when you read messages off the stack you see if it has no userID (meaning it's open to everyone) or if it has a userID then you compare the current user with the ID on the message before you send it to them. This same idea applies when you're using channels -- only show messages to users that are in the same channel as the one on the message. \$\endgroup\$ – Jade Aug 28 '15 at 19:13
  • \$\begingroup\$ At least that's what I do on SmartFoxServer \$\endgroup\$ – Jade Aug 28 '15 at 19:14
  • \$\begingroup\$ @Jade I'm sorry, on paper it's obvious and easy, I'm glad you're trying your best to help, but if you do not know UNet I don't see how generic advices, however correct, can help me in this situation. I hope you understand? \$\endgroup\$ – o0'. Aug 28 '15 at 20:21

What you want is NetworkServer.SendToClient or NetworkServer.SendToClientOfPlayer. You'll want to read up on Network Messages, and then check out NetworkServer here.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.