Search Unity

Third Party Photon bolt marchmaking

Discussion in 'Multiplayer' started by r31o, Dec 5, 2021.

  1. r31o

    r31o

    Joined:
    Jul 29, 2021
    Posts:
    460
    Hello,
    Currently in my game, to play you have to press a button "Start server" to be a host or "Start client" to join a room as a client (Start server uses BoltLauncher.StartServer() and Start client uses BoltLauncher.StartClient()).
    I want to make it that when you press a button "Play" it tries to join a random room and if cant, create one.
    How? Im a noob in bolt matchmaking, so my matchmaking code is the one from the tutorial of the website, but I know ho to use the other aspects of bolt.
     
  2. r31o

    r31o

    Joined:
    Jul 29, 2021
    Posts:
    460
    Also I sorry for the error on the title.
     
  3. r31o

    r31o

    Joined:
    Jul 29, 2021
    Posts:
    460
    And for the error on the last comment. Im Spanish, and my english is terrible.
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    You should attempt to join a random room (session) first (on press of the Play button). If that doesn't work, let the client create a room and the next player's join random will find that.
    Of course this works only with at least some players being online but .. this is the nature of almost any matchmaking approach.
     
  5. r31o

    r31o

    Joined:
    Jul 29, 2021
    Posts:
    460
    Ok, now I understand.
    One question: Does the JoinRandomRoom return someting? like true if it works and false if it not, so I could make something like this:
    Code (Csharp):
    1.  
    2. if(JoinRandomRoom())
    3. {
    4.     //Room joind, IDK how exactly is named the JoinRandomRoom
    5. }
    6. else
    7. (
    8.     CreateRoom(somePort);
    9. )
    10.  
    Will this work (I know that the join and create room methods are different)
     
  6. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    Check the reference API.
    It returns if the operation (join random room) can be send to the (current) server. The return does not indicate if you found a room or not. That takes a roundtrip and you don't want the main loop to be blocked until that's done.

    Have a look at ConnectAndJoinRandom.cs for some ideas.
     
  7. r31o

    r31o

    Joined:
    Jul 29, 2021
    Posts:
    460
    Thanks for your reply. Where is ConnectAndJoinRandom.cs? is a script on the extras? I deleted the extras.
     
  8. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    It should be in the PUN package, yes. Simply start the import again.
    Assets\Photon\PhotonUnityNetworking\UtilityScripts\Prototyping