How to correctly make same scene with multiple rooms

Options
MaZy
MaZy

Hello,

the question is simple but not easy to describe. We are creating multiple scenes. Every scene has own room. We want to give the same name. Lets say scene_a and scene_b. Players can choose what scenes they are want to play and not what room they want to join.

PhotonNetwork.JoinOrCreateRoom("scene_a");

Now we want to limit it lets say to 8 players. But if players still want to play scene_a and its full we want to create another room but how we should do this exactly? With counting up and adding the numbers to the room name like "scene_a 1" 2 3 4 etc.?

If yes, how can I manage the numbers. If an user need to create another room we wouldn't know the next number.

If not how can I manage this. Basically I need to identify ALL rooms which uses the scene_a. can OnRoomListUpdate give me the information? If I can manage otherwise I could just do random numbers behind room names.

Or I just saw JoinRandomOrCreateRoom does this function already this?

Answers

  • Dibbie
    Options

    OnRoomListUpdate may be a good way of doing this, once you create a room and you know which scene it should load, you can publish that as a property to the lobby, then use OnRoomListUpdate to pull all your rooms with that property and check against it - because its often better to send as little data as often as possible, it could be a good idea to have that property be the index of the scene you want to load, though if you use automaticallySyncScenes then Photon will automatically create and manage a property with the key "CurScn", though im not completely sure if that also get automatically published to the lobby properties for that room

    JoinRandomOrCreateRoom will join any room that has less players than max, so if you dont care which room a player joins it could be an alternative, however in either case I think youll have to filter all published rooms, and determine your own logic for when to create a new room with the same scene index/name, you may have some more specific edge-cases to solve

  • MaZy
    MaZy
    edited November 2022
    Options

    Thank you for the answer.

    I fully could implement this. JoinRandomOrCreateRoom helped to make this. We used the letter "s" for the scene name and used in lobby properties and room properties. With this together it worked like we wanted.

    We wrote also a "custom" matchmaking which manages the room list. We call them OpenWorldRoomlistManagement. It manages the OpenWorldRoomlist and OpenWorldRoomInfo (Room Info with addtional information). It has values like TotalPlayerCount (counting all players in this world/scene). It was tricky but it works.