- Home /
RPC.Others vs multiple RPCs
I want to send RPC with some data only to players that are close enough to current player. For example, we have 100 players.
function Update(){
networkView.RPC("Function", RPCMode.Others, someData);
}
vs
function Update(){
for(var player : NetworkPlayer in PlayersList){
if(range < 100){
networkView.RPC("Function", player, someData);
}
}
}
Question: sending RPC with RPCMode.Others is cheaper by performance or bandwidth than sending multiple personal RPCs, or in fact RPCMode.Others is the same as 99 times send RPC("", somePlayer : NetworkPlayer)?
Just a comment: If you're trying to do large environments like that, RPC may not be the right technology to do so. You're entering $$anonymous$$$$anonymous$$O territory, and may want to consider technologies like SmartFox and Photon to handle the communications. There are ways of integrating them with Unity, either yourself (if you're an expert; there are many examples) or with 3rd party code like Jibe.
We've used SmartFox, and you can easily send a single message to the server, then write a simple extension there to take the player positions and deter$$anonymous$$e who to send the message to - one message to the server, and one message from the server to every player that needs it.
Thanks for your comment Julien. I have read SmartFox documentation and tutorials. It's very flexible and functional, but I didn't find sugnificant features that can't be implemented by unity scripts. Javascript's functionality is enough for my purposes - to create rooms, groops, authoritative server and so on. But am I missing something? Is there some limitations to concurrent users number, or sugnificant performane loss when CCU number exceeds several hundreds? What does SF and Photon have that can't be made by unity tools?
Right now my communications looks like this: - Update 15 times/sec. - Users send their inputs to server(only those that have been changed) - Server sends positions, rotations and few other bytes of all users as one byte array using single RPC.Others.(only those bytes included that have been changed) Calculated traffic for player at 100 connected users is 1.26$$anonymous$$B/sec up and 10.20$$anonymous$$B/sec down including headers and security bytes.
Answer by Elric · Jan 08, 2013 at 09:55 PM
Made some quick testings. Created simple scene with no graphics, only GUI. Server and 10 clients on local machine. In Update:
if(mode == "Others"){
networkView.RPC("Do", RPCMode.Others, Data);
}
else if(mode == "Each"){
for(var player : NetworkPlayer in Network.connections){
networkView.RPC("Do", player, Data);
}
}
var scsvsw : StreamWriter = File.AppendText("test.csv");
scsvsw.WriteLine(mode+";"+1/Time.deltaTime); // mode and FPS
scsvsw.Close();
Function "Do" does nothing. Var "Data" is byte[4096]. Results: 68.5812 FPS in Others mode vs 64.2191 FPS in Each mode. But most times FPS is 60 in both cases, and it jumps to 280 about once every second in Others mode and to 260 about once every 4 seconds in Each mode.
Does anyone knows the reason of this peaks of FPS? Also is there any way to get Actual bytes send/recived in script?
I'll post more testings after implementing both modes in game.
Your answer
Follow this Question
Related Questions
RPC and State Synchronization bandwidth decreasement 2 Answers
Really quick/easy question about RPCs 1 Answer
RPCMode.All Question 1 Answer
How to send BUFFERED RPC calls to specific player? 0 Answers
RPCMode.AllBuffered Basic Question 1 Answer