- Home /
RPC to a single client
Hello,
I just have a small question to help me understanding the behavior of RPC.
Let's say I want to call a function from my server on one of my clients using a RPC. I will use RPC.mode all or others. However, if I understand it well, it will send the request to all my clients, and not specifically to the one I need. I figure that I can filter the client on which I want to perform the action with the help of an ID, but isn't it overkill to send a command on all clients and check individually on each if it has to be performed or not ? (what if I want to create a MMO ?!) Is there a way to call a request to a specific client (with the ip or the ID ?)
Thanks to anyone who will help me to understand this =)
Answer by syclamoth · Nov 29, 2011 at 04:22 PM
This one got me for ages (Which basically makes me incredibly dumb, but never mind that)
If you scroll down in the NetworkView.RPC page, you'll find a second version of the function, that gets called with 'NetworkPlayer' instead of RPCMode!
So, instead of using 'All', 'Others', 'Server' or whatever, use
networkView.RPC("FunctionName", playerToSendMessageTo, paramaters);