Different send rate per photonview
Options
Comments
-
Currently, that's not built-in. You could modify the code to skip every n-th update in your OnPhotonSerializeView. Just don't insert an update into the stream.0
-
Is this still the official way of reducing send rate? I'm thinking of doing that for NPCs (enemies in this case), while the player characters have a higher update frequency.0
-
@Tobias if the sending side skips writing to the stream within OnPhotonSerializeView, based on some arbitrary condition - will OnPhotonSerializeView still be called on the receiving side? I want to do conditional updates, kind of similar to the concept of "update on change" so I can skip writing things into the stream if no update is required. I'm aware of the built-in behaviour within PhotonTransformView, but I need to do something similar within custom send/receive scenarios.
0 -
I think I have a solution (although it may not be the most efficient). You get an out of range exception because OnPhotonSerializeView will be called regardless of whether you write anything to the stream or not. My idea is to write a boolean every serialize to indicate whether your data will follow. When reading, receive that boolean and only continue receiving the other objects if that boolean is true.
Example:public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.isWriting) { stream.SendNext(shouldSend); if (shouldSend) { //Send other data } } else { bool shouldReceive = (bool)stream.ReceiveNext(); if (shouldReceive) { //Receive other data } } }
0 -
Just use Raise Event instead of OnPhotonSerializeView0