Best Strategy for Map Syncing

Options

Hey there,

I've been using Photon to build an RTS game that I'm working on and have been quite pleased with the result thus far but I'm hitting a bit of a wall. I need to sync procedurally generated maps between two players. Right now, the master client generates JSON which just holds the location of bases as Vector3's and I add this to the room property Hashtable. Right now, I only need a single copy of each base so I have the master client instantiate those along with each bases arbitrary data. The problem is, the other client has the correct objects in the scene but doesn't know about the base's auxiliary data. What is the best way to sync this data so that all clients share the same structure? For example, a base needs to know about it's capture points as they are added after the GameObject is instantiated.

The biggest problem I see is that I use PhotonNetwork.Instantiate to create the networked objects if we're the master client, but I need this object on the non-master client as well but all I have is the position. The few ways I thought about doing it was listening to OnPhotonInstantiate and then doing any operations I need to on that object once I received the callback. The other way is packing as much data as I could into the map JSON so that even if the client wasn't the one creating the objects, but I still foresee some issues with this. Any insight as to going about this would be very helpful for me!

Thanks!









Comments

  • czk
    Options
    Another way I thought of doing it is after the master client creates the base object, I send an RPC to the other client with any arbitrary data that base needs and assign it accordingly so each base is synced.
  • czk
    Options
    To anyone who stumbles across this post, I was able to get this to work properly by sending an RPC after the master client instantiates the object. I passed the viewId into the RPC and then used PhotonView.Find(viewId) to grab the object and continue any processing from there.