Level data sharable on start?

Tutorials work fine, however made from pre-made scenes (static data).

I am testing a bit more in depth PON with a bomberman-like game where every cells are first listed randomly, including the wall data (if contents a hidden item).
Once the first player creates a new room, the level is generated on start.
Then how to share that script generated level data to other players while joining the room?

For now I only understand PON from the player instantiate system, including sub items such bombs dropped by the player (PunPRC)... Everything is working pretty much well.

How about data unrelated to player then?
How to deal with those to update them in runtime and sharing to other player?

Any url to documentation would be welcome...
Thank you! :)

Comments

  • StephenLambert
    edited August 2
    Really interesting tread :D I will w8 with you c:
  • Did you have a look at the "Procedural Demo"?
    This shares a lean seed for the room and every player is able to generate the same scene from that. I think this could be usable in your case, too?!
  • Tobias wrote: »
    Did you have a look at the "Procedural Demo"?
    This shares a lean seed for the room and every player is able to generate the same scene from that. I think this could be usable in your case, too?!

    Woops a bit delayed on this.
    Yes it seems to match what I need!
    Thanks!
  • Alright then I am having that issue while sending data to PON :
    https://forum.photonengine.com/discussion/16726/exception-write-failed-custom-type-not-found-unityengine-transform

    Unfortunately it doesn't mention a very custom class.

    On my side that is a full LevelData containing a dozen of setting and Vector2Int arrays...
    ExitGames.Client.Photon.Hashtable properties = new ExitGames.Client.Photon.Hashtable
    {
    	{LevelDataPropertiesKey, levelData}
    };
    
    PhotonNetwork.CurrentRoom.SetCustomProperties(properties);
    

    Is that possible? Or should it be flatten as the sample project as below ?
    Hashtable properties = new Hashtable
    {
            {SeedPropertiesKey, Seed},
            {WorldSizePropertiesKey, (int) WorldSize},
            {ClusterSizePropertiesKey, (int) ClusterSize},
            {WorldTypePropertiesKey, (int) WorldType}
    };
    
    PhotonNetwork.CurrentRoom.SetCustomProperties(properties);
    
  • samavan
    samavan
    edited August 10
    Self note :

    Best is to serialize custom class.
    Below my routine in case someone is interested :

    Custom Class :
     public class LevelData
        {
            public Vector2Int [] SomeDatas;
    
            public static LevelData Parse(string rawJson)
            {
                return JsonConvert.DeserializeObject<LevelData>(rawJson);
            }
    
            public string Serialize()
            {
                return JsonConvert.SerializeObject(this);
            }
        }
    

    Send to server :
    ExitGames.Client.Photon.Hashtable properties = new ExitGames.Client.Photon.Hashtable
    {
    	{SeedPropertiesKey, levelData.Serialize()}
    };
    
    PhotonNetwork.CurrentRoom.SetCustomProperties(properties);
    

    Receive from server :
    levelData = LevelData.Parse((string)propertiesThatChanged[SeedPropertiesKey]);
    

    However I understand how to refresh on OnRoomPropertiesUpdate() which is fired only if master update the data... but is there a way to access the data right on Player enter room from the PhotonNetwork?