- Home /
RPC ordering - is it really preserved?
If two clients send an RPC message Foo to the same object, the documentation seems to suggest that these both go to the server, then are sent (in the same order) to all clients, including those who sent the messages. Is this what the documentation means?
I don't seem to get that result. To me, it seems that RPCMode.All actually sends the message to self out-of-order. i.e. it effectively tells the server to pass on the message to everyone else, but short-circuits the send to itself, thereby causing different clients to receive the RPCs in different orders (always themselves first if they sent it).
I've currently worked around this by first sending a proxy message only to the server and then having the server send the real message to everyone - I of course then get the expected behaviour, but I'd rather not have to double-up all my RPC calls.
Unity3, BTW.
Answer by Atnas1010 · Oct 28, 2010 at 11:05 PM
As I understand the documentation:
RPC calls are always guaranteed to be executed in the same order as they are sent.
It means that the RPC calls are always recieved in the same order on every client, if the RPC calls are sent out by one person.
As you observed, Unity is smart enough to "short-circuit" RPC's to self, and send it directly to the other clients. If it did it the way you expect it to, it would create a lot of "unnecessary" traffic.
Might I ask why you need the behavior you described in the first paragraph?
Each client gets to say "I hit X for N damage". Clients need to receive those in the same order so that the killing blow is attributed to the right player. Yes, I can use timestamps and buffers etc. as another alternative solution. The particulars of my game are such that it doesn't matter much who killed (but it DOES matter that all clients agree who killed). Certainly the docs could be clearer, not leaving "if sent out by one person" to our imaginations.
Couldn't you when you receive the RPC calls, look at the time they were sent, and from that decide who gets the killing blow? I haven't tested this, but I think it would work. It might have a short moment of confusion where the client says that he killed it, until he receives a message saying someone else did.
But it might be best solution making that part of the networking authoritative (as you are doing now)
Your answer
Follow this Question
Related Questions
Can I use RPC calls in an Update function ? 1 Answer
Deleteing Objects created by Clients 0 Answers
Network - Killing Player, Then Respawn - Issue with RPC 1 Answer
List clients connected? 2 Answers
RPC a lot of lags (Photon) 0 Answers