- Home /
Unity.Networking (UNet) RPC to Specific Player? Master Server?
Just a couple of questions in regards to the new UNet system.
First, is it possible to send an RPC to a specific player? For example I have a chat system which allows sending messages to everyone, a specific group like a clan or party, or whispering to a single player. Is this done with the [Command] and [ClientRpc] attributes or with SendToClient()? If any one has any general pointers I would greatly appreciate it!
Also my second question: My game currently relies on a masterserver. Is there a masterserver aspect to UNet, or only direct connect?
Thanks!
Answer by seanr · Jan 06, 2016 at 06:27 PM
There is a "TargetRpc" being added to UNet that does this - probably in 5.4
Hello I have a problem, I want to sync a component betwen host and client but I dont found the way, I tried to use [command] to get the current state of a GameObject and return it to the client so he can "refresh" his component but that doesnt works because I have to set the return type to void so I dont know what I have to do Please Help!
[TargetRpc] was added in Unity3D 5.4. https://docs.unity3d.com/ScriptReference/Networking.TargetRpcAttribute.html
Answer by Ashkan_gc · Jan 04, 2016 at 08:35 AM
Currently ClientRPCs will be sent to all clients and not only one of them. This is a good feature to be added however. In Client if you want to receive only at owner side you can check isAuthority to see if you should process the call or not but it means everyone will receive it and only owner processes it.
Answer by tanoshimi · Jun 11, 2015 at 07:22 PM
To send a message to a particular client: http://docs.unity3d.com/ScriptReference/Networking.NetworkServer.SendToClient.html
For MasterServer-type functionality, see: http://docs.unity3d.com/Manual/UNetInternetServicesOverview.html
Thank you very much for your reply! I had a hunch SendToClient would be the way to go... I'll give this a shot when I get a chance. I don't think the internet services will work for me. I plan on having multiple servers with a maximum of 500 clients connected on each.
If I'm honest, I'm still getting my head around uNet myself... if you do solve your problem be sure to post back here and let us know!
Your answer
Follow this Question
Related Questions
NetworkManager auto deleting client gameobject when calling it 1 Answer
Easy way to make my own Simple Master Server? 0 Answers
UNET - Why is my NetworkInstanceID equal on both clients when receiving ClientRpc? 1 Answer
Unet network message or Command/RPC 0 Answers
ClientRPC not getting sent. 0 Answers