How can i set the map randomly when making a room?

Options
hello!
I am using PUN to make a competitive game.

and i hope to load a map randomly out of 3 maps.
i mean, not instantiating for random structure, but (such as game OverWatch) loading randomly certain map i designed .

i can use "instantiate" code for map, but by worries about size of the game i would like to know more reasonable ways.
So in this case, how can i solve this problem? help me...

Comments

  • DandS
    Options
    Hi,

    you can use the room CustomProperties to share the name or index of a map with all players in the room. when you create a room just choose a map at random from a list of maps that's the same for all players, and set the room's corresponding customproperty to the index or name of the chosen map, then every other player can retrieve that information and load the correct map on their end.

    CustomProperties are explained in the doc here under CustomProperties: https://doc.photonengine.com/en-us/pun/current/manuals-and-demos/synchronization-and-state

    Have a good day =D
  • Hi @Senma,

    DandS has already suggested a good approach which you can definitely use. Another option you have is to enable the automatic scene synchronization by using PhotonNetwork.automaticallySyncScene = true; in your code. Having enabled this option, the MasterClient can load a random selected level by using PhotonNetwork.Load(...). This way, the currently active scene is stored in the Room Properties and each connected client will load this scene as well.
  • Senma
    Options
    Thanks @Christian_Simon , @DandS !!

    i will try that ways you recommended. i am not good at programming so i try both of the ways hehe :)
    Have a good Day!! Thanks