- Home /
Is it "bad" to use RPCs to synchronize movement?
I hear that RPCs can be slow if you're using them to synchronize player positions. People say to use NetworkViews instead.
However, my situation is a bit more complex... I'm using RPCs as "pings", which go to straight to the server. The server receives the ping, then sends an "update" to all other clients that need to know where the pinged player is. Those clients simulate where the player is by using a list of places that the player has to go, and having the player move through each position in the list one by one, kind of like following the same path the pinged player took. Each client keeps track of the last time it pinged its position, and only pings it if it's been so much time since then.
The way I've set it up makes it hard to just "start using NetworkViews", because I relied on the method of using RPCs to convert positions into 'orders'.
My question is, is it "bad" to do it this way? Will I experience a lot of lag issues if I had lots of players "pinging" their position and jumps and everything through RPCs instead of NetworkViews? If so, would it be best to use a NetworkView with Unreliable state synchronization for the best performance?
Thanks for any answers!
Answer by Dave-Carlile · Dec 18, 2012 at 02:15 PM
If you're sending them as "orders", then what you're doing should be fine. There are potential issues though, depending on what sort of game it is. Due to floating point rounding, execution order and such, it's possible that clients may simulate the movement slightly differently, which can cause all sorts of problems.
For example, when doing pathfinding, it may cause a character on one client to choose a different path from another client, and all of the ramifications that follow from that.
So, this may or may not be a problem for you. If only the target position matters then you're probably fine. If where the player is while moving to the target position matters you may have some problems.
The game is an FPS, so I don't see many problems co$$anonymous$$g from rounding and such. The system works pretty well now, I just heard some people say that if one RPC fails to reach the target, then all others will stop until it's re-sent and received, or something to that effect.
That is true - since RPC calls are guaranteed for both delivery and order, if once is missed they all queue up on the client while it waits for the missed one to be resent. This can cause some bad moments of lag. You should really use the NetworkView synchronization for an FPS game.
Alright, looks like it's as I feared... Thanks for the help!
Your answer
![](https://koobas.hobune.stream/wayback/20220613085607im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Networking Error! 0 Answers
OnSerializeNetworkView issus in my 2D game 3 Answers
Overloading RPCs 1 Answer
RPC not sending and not giving an error? 0 Answers
getting error with networkView 0 Answers