Search Unity

Other How not to join private room or room with bet amount on PhotonNetwork.JoinRandomRoom() function call

Discussion in 'Lobby' started by BlackPantherGamer, Mar 28, 2022.

Thread Status:
Not open for further replies.
  1. BlackPantherGamer

    BlackPantherGamer

    Joined:
    Jan 13, 2022
    Posts:
    1
    I am developing a multiplayer racing game in unity using PUN2. I want to create 2 types of rooms. The first type is that players create a room with some constraints that max players, no of laps and bet amount (that may be called a private room or price to pay to join the room). And 2nd type is the free room type. For this, I've used
    JoinRandomRoom()
    function. So the issue is that when I use the
     JoinRandomRoom()
    function it joins the First type of room (without even paying the price). Now I want to define constraints for this type of room is that when the
    JoinRandoomRoom()
    function calls it must not be allowed to join the first type of room if there is no free room available it creates a new room.

    I have found 2 overloads of
    JoinRandomRoom()
    function but couldn't understand how to use them. One thing I also found that while creating the First type of room I could add some additional strings like the word "Private" in starting of the Room name so that I can keep check of such rooms but didn't get how to pass such conditions to
    JoinRandomRoom()
    function that if the room name starts with the word private do not join that room and create a new one.
     
  2. UnityKip

    UnityKip

    Unity Technologies

    Joined:
    Nov 15, 2021
    Posts:
    36
    Hi @BlackPantherGamer

    This question appears to be for Photon Multiplayer which is unrelated to Unity's Lobby service. Let me know if you posted here in your usage of a Unity sample and I can try to assist with any issues you may be encountering. If you need help with Photon, you will need to reach out to the developer for further assistance.

    With that said, it looks like you can the third overload listed in their docs to set a TypedLobby which will let you create different types of Rooms and force a join into a specific type. Note that this functionality is available in Unity's Lobby service through Filters.

    Good luck with your development!

    Regards,
    -Kip
     
Thread Status:
Not open for further replies.