- Home /
Which is better: NetworkView or RPC?
I recognize that the two function differently but for my use, they both can serve the same purpose. So when periodically syncing the position, rotation, and animation state (integer), which is better to use for best networking performance? or is the difference negligible?
Answer by Addyarb · Dec 23, 2014 at 12:31 AM
It's better to fire an RPC. NetworkView, if you're using reliable data, is going to keep it updated always. However, if you turn your network view off and just fire an RPC via the networkView, then that saves a lot of overhead.
However, you'll want to set some conditions to fire your RPC. For instance:
if(Vector3.Distance(myTransform.position, lastPosition) >= 0.1)
{
//Capture the player's position before the RPC is fired off and use this
//to determine if the player has moved in the if statement above.
lastPosition = myTransform.position;
networkView.RPC("updateMovement", RPCMode.OthersBuffered,
myTransform.position, myTransform.rotation);
}
Ah, tyvm. Just a sidenote, why have RPC$$anonymous$$ode set to OthersBuffered rather than Others? I never really understood the practical difference.
Good question. As far as I know, different buffering allows for different syncing to be applied. OthersBuffered in this case, is sending the RPC, and buffering those whom are not you. AllBuffered sends the RPC and buffers everyone including you. I'm not the best person to explain this to you, but I do believe AllBuffered will buffer your parameter to make it more realistic to everyone, where as OthersBuffered will give you feedback based on your actual location, and buffer everyone else so that no one viewer of you has any better idea of where you are than the other.
So, if you're trying to sync your player character with the rest of the world, you'd want to use OthersBuffered so that when you move forward, you will get immediate response ins$$anonymous$$d of waiting for everyone else to buffer it. However, if you're moving the sun across the sky, it's better to AllBuffer it so that all players get the same amount of light no matter how good their ping is.
Hope that makes sense, and that I'm right.
Your answer
![](https://koobas.hobune.stream/wayback/20220613174709im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
networkView not called on Child objects? 0 Answers
OnSerializeNetworkView issus in my 2D game 3 Answers
Overloading RPCs 1 Answer
Couldn't invoke RPC to server after Network.Destroy 0 Answers
NetworkView conflicts between Levels 1 Answer