How to stop sending data without errors?

Options
Hello,

I'm building an RTS game and thinking of how to save some data from having to be sent over the network. What I'd like to do is have my "Transform View" script STOP sending data whenever a unit (game character) comes to the end of its path. Because, at such times, it doesn't need to send its position and rotation information.

Now I have my "Photon View" on my units set to the observe option of "Unreliable on Change". However, this still sends data (i.e. the position and rotation) even if my unit is not moving at all. Is it supposed to in this mode? If not, then I can look at my own code.

I've tried hooking into my own movement script and saying that if my units path is null, then the writing and reading in the "OnPhotonSerialize" view function should not operate. However this often causes invalid casting errors for some reason, and things just don't work.

So far, I havn't found a good way to stop the sending of data when my units are stationary without a lot of errors being thrown by the OnPhotonSerialize view function. Any help or ideas is appreciated.

Comments

  • vadim
    Options
    Hi,

    "Unreliable on Change" is for stopping sending data when object does not move as described in "Observe Options" section of https://doc.photonengine.com/en/pun/current/getting-started/feature-overview.
    How do you know that PUN still sends data?
    What's observed by PhotonView? Object's transform?
  • Velo
    Options
    Hi vadim,

    I know PUN is still sending data because I've placed a "Debug.Log()" command within a "if (stream.isWriting)" condition check (in the PhotonSerialize view function). The stream still writes even while the unit/character is stationary.

    My unit's Photonviews are observing the "Transform View" component (not the normal Unity transform), and also the "Animator View" component (both which come with PUN by default now).
  • vadim
    Options
    OnPhotonSerializeView methods does not send anything via network. It only pushes current values to PUN serializer which decides if something has changed and needs to be sent.

    For real traffic value, enable stats PhotonNetwork.networkingPeer.TrafficStatsEnabled = true and check how much PhotonNetwork.networkingPeer.TrafficStatsOutgoing.TotalPacketBytes changes per second.