Streams vs Photon Transform View

Hi all.
I was reading this article
https://doc.photonengine.com/en-us/pun/current/demos-and-tutorials/lagcompensation
So it is basically about streaming transform values.
How is it different with synchronizing with Photon Transform View and Photon RigidBody2D View?
Do I need to apply both (stream and transform/rigidbody view)?
Or transform/rigidbody view is just an easy way of the same thing?

Comments

  • Hi @luvjungle,

    How is it different with synchronizing with Photon Transform View and Photon RigidBody2D View?


    Both are actually using the same function (OnPhotonSerializeView) to exchange data between clients, but they have different approaches how to synchronize objects, which is the only difference between the built-in solutions and those on the above mentioned documentation page.

    Depending on PhotonNetwork.sendRateOnSerialize, OnPhotonSerializeView is called multiple times per seconds (by default 10 times per second) to exchange data between clients. All of the included Photon*View classes are using OnPhotonSerializeView, too, to exchange data between clients in order to synchronize objects.

    Do I need to apply both (stream and transform/rigidbody view)?


    No, one of them is enough.

    Or transform/rigidbody view is just an easy way of the same thing?


    Yes, exactly.
  • Thank you for your answer.
    Can you please clarify if PhotonNetwork.sendRateOnSerialize affects exchange rate of Photon*View classes too?
  • Just take a look at its comments in the code:
    /// <summary>
    /// Defines how many times per second OnPhotonSerialize should be called on PhotonViews.
    /// </summary>
    /// <remarks>
    /// Choose this value in relation to PhotonNetwork.sendRate. OnPhotonSerialize will create updates and messages to be sent.<br/>
    /// A lower rate takes up less performance but will cause more lag.
    /// </remarks>
    So yes, changing this value affects the Photon*View classes as well.