Updating PhotonView.instantiationData & some general advice

Hello,

I am currently developing a tool that allows users to create diagrams collaboratively. Basically they can drag and drop nodes into a diagram view, drag them around the view. Edit properties on them etc.

Each node has a photonView and I send the init data using PhotonView.instantiationData which stores a hashtable of all my init values(e.g viewID of parent node, position etc).

I know I could sync the node positions by observing the transform however my nodes don't move very often and I am able to get OnDrag events that tell me when they do so I currently send RPC when a node is being dragged. Once a node has been dragged I would like to be able to update the instantiationData with this new position for any clients that may join late. Is it possible to do this or is this the wrong thing to do? Alternatively I was also thinking of having a RPC that could request the latest data for a node from the master.

What would be the best way to ensure that the nodes correctly sync across the clients? I know I could use the OnPhotonSerializeView however the data wont change that often so it seems like a lot of redundant network traffic. At the moment I plan to use RPC when ever a value changes which seems fine except I am unsure how to handle a new client joining. I could do some sort of request latest data RPC? Is there a more elegant solution than this?

Thanks

Karl

Comments

  • I just read in the documents that If you write no data to the PhotonStream, the update is not sent when using OnPhotonSerializeView so I think this could be the way to go to sync changes.
  • I added a new "Synchronization Option" into PUN 1.24 with the unwieldy name: "Unreliable On Change".
    This is built for rarely changing values and it checks if your synced values changed, sending only new updates. If the values stay the same, they are sent reliable once (to make sure everyone has them) and stops sending (due to lack of diff).
    Depending on your needs, this might be an alternative.
    The solution you describe is of course even better, as your code can easily decide if updates must be sent or not.