- Home /
Does RPCMode.All perform poorly?
I am ironing out some kinks in my networked multiplayer game, and I notice in pretty much every code sample I've seen using Unity's networking, if someone wants to call an RPC function on all connected clients they do something like:
function Update(){ If(Input.GetButtonUp("Fire1")){ DoSomething(); networkView.RPC ("DoSomething", RPCMode.Others); } }
@RPC function DoSomething() { //do something here }
Calling the function normally locally, and calling the function via RPC to all the other connected clients with RPCMode.Others.
How much less performant is doing the same thing by just using RPCMode.All, and removing the local function call alotogether?
It seems exceptionally difficult to get networking answers around here :/
Answer by PrimeDerektive · Jan 12, 2011 at 09:03 PM
Upon testing and research, apparently RPCMode.All has a bug where it doesn't always run the function for the player calling the RPC, which is why it is best practice to call the RPC function both locally as a normal function and and as an RPC.
I know it's a quite old question, but the only situation where it won't be called on the local player is if the server executes it. The server can't send a message to itself. When a client sends the message it goes to the server and the server distributes it to all clients including the caller.
That's another reason why it's better to use .Others. It doesn't need to send the rpc back to the sender --> one packet saved ;)
@Bunny83 I am testing this right now, and .All sends the RPC to all players (including the server) regardless of whether or not you're the server.
Your answer
Follow this Question
Related Questions
Rpc client issue 0 Answers
NetworkView.RPC: Can you nest RPC calls? 1 Answer
Pass a Transform into a Function 1 Answer
RPC calls to a function with a same name in different scripts 1 Answer
RPC function order 0 Answers