A Question of Best Practice

I've elected to use PUN. RPCs are insanely easy to use for firing off events, but I can't seem to find a similarly high-level construct for synchronizing data on arbitrary objects. I'm keeping player stats in the CustomProperties Hashtable and it seems to work well, but for non-player entities, I'm a bit stumped. Is data included with instantiation synchronized?

Consider a Foo Dragon with 100hp. What's the best way to keep that value in sync? I want to avoid cobbling together some half-assed solution if the API already includes a better method that I've overlooked.

Do I use OnPhotonSerializeView as seen in the Marco Polo tutorial? That seemed inefficient for values that are sparely changed, but I guess I don't need to worry about that with delta compression enabled?

Comments

  • Do I use OnPhotonSerializeView as seen in the Marco Polo tutorial? That seemed inefficient for values that are sparely changed, but I guess I don't need to worry about that with delta compression enabled?

    That's one way to do it, right. Delta compression will go through each of the entries in the PhotonStream and check if it's changed. That's one way to auto-reduce traffic caused by sparse updates.
    This is relatively simple to use but is not as good as your own, custom solution would be. You could send only the data needed in the first place. Then you would probably turn off delta compression and one or more values in the PhotonStream would tell the receiver what's coming next ("HP changed", "HP and position changed"). Something like that.