About the PhotonView


I've been crawling in the doc and the forum but I still haven't find answer to my questions.

Basically, we are making a game with up to 300 objects that we try to keep in synch across our clients. I'm using the PhotonView with OnPhotonSerializeView and it's working well. Still I have basic networking questions and maybe someone could point me to the chapter in the doc or knows the answer.

How can I know when the OnPhotonSerializeView / isWriting will occur? Is there any way to change the frequency?

I know I could use an RPC and get a periodic function to call the RPC but I'm wondering if there is any reason to use one or the other?

Also, when using OnPhotonSerializeView, is it UDP, RUDP or TCP? Is there a way to configure that? Same question about the RPC...

Finally, when using OnPhotonSerializeView and RPC, is there a Nagle algorithm or anything similar happening in the background or should I code one myself? I'm wondering how it works because I have over 300 PhotonView calling OnPhotonSerializeView but I'm far from the 300Msg/s in my room so there must be something going on in the background.

Any help is appreciated



  • Sorry for the late reply. Not sure if you still got those questions...
    Are you still active?

    The frequency of OnPhotonSerializeView is configured via PhotonNetwork.sendRateOnSerialize.
    PhotonNetwork.sendRate configures how often packages are aggregated to be sent but you should not need to set this: After OnPhotonSerializeView, sending is done, too.

    PUN uses UDP with on-demand reliability. The PhotonView's component defines if everything of this view is sent reliable or not.

    Using RPCs is best for infrequent method calls. The overhead is not very different from what OnPhotonSerializeView does.
    If you just want to call some method in intervals, don't use networking for that. Use some timing per client.

    You don't have to implement something like Nagle but keep in mind that PUN is built to make synchronization of a few network objects easy. It's not totally tuned for hundreds of objects. So test your stuff with the worst load you expect to see if it works. A lot of traffic can reduce connection stability. Sending as much as possible in a unreliable way is a good start allow fast recovery from issues.