RPC vs Reliable Delta Compressed

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

RPC vs Reliable Delta Compressed

Dima
2013-05-22 14:41:28

Hey guys ;)

I'm working on a project using Photon Cloud. Was wondering about when do I need to use RPC/Reliable/Unreliable data.

With my understanding, I trigger one time events with RPCs (sound, health loss, etc.), send data subject to a lot of changes with unreliable (like position, etc), and use Reliable only when an object is subject to changes but only few times.

Am I right?

What I am trying to do right now is to send changes of a gameobject properties (a boolean to toggle the field of vision (enable/disable mesh), team assignation (enum), etc.). Those values are updated (and used to keep informations about the current state) whenever the masterclient makes a modification, then the corresponding methods are triggered to validate the changes.

What is the best way to send those changes please?

a) Observe using Reliable Delta Compressed and check in OnPhotonSerializeView if the values have changed, then trigger corresponding methods (is there a way to know which variables have been sent via the stream? since only changed values are sent, I would like to get which ones has in order to trigger the associated methods)

b) Use RPC to trigger those events (enable/disable sight field, switch team)

c) Use Reliable Delta Compressed to store new values, and in a Update function check if received ones are different than the current ones (doesn't sound proper)

The information that I miss is the Advantages/Drawbacks of RPCs and Reliable Delta Compressed. Which one is most likely to saturate the network, at what extends, frequency, and type/quantity of data?

Thank you in advance !

Dima

Comments

Tobias
2013-05-22 15:50:38

Actually, I never tested in-detail how much more data a RPC uses versus an OnSerialize call. Both should be relatively close to each other. At least since PUN 1.20 which abbreviates known RPC names to bytes. Delta Compression will skip any value in the stream that's not changed since last sent. If all values are identical, the whole update is dropped. There is no list of what has been skipped. This would be a little like sending an RPC only when something changed. The benefit here would be you could send the whole state. If someone joins the room late, OnSerialize will send a full update (ignoring deltas to previous updates which went to users in the room only).

Using RPC could be fine, too. Even more if you send no other updates for an object.

Unreliable is fine for any data you replace soon. Positions are just one example of data that's often updated. It depends on what you need to send.

In general, your object might know best if they are updated or not and if they need to send an update. Constant updating is just the fast and lazy way to implement synchronization.

Dima
2013-05-23 07:48:19

Hey Tobias, thank you for your explanations!

So, using Delta Compression or RPC is quite the same thing, but:

  • Delta compression send only what need to be sent and it knows when (it checks for eventual changes before sending it via the network)
  • RPC send the whole stuff but is more judicious if there won't be any update later that I would have to handle myself by checking values and re-triggering the RPC. Plus, with RPC I know exactly what I send and when

Good to know, thank you again !

Back to top