Search Unity

Auto Matchmaking or Pairing?

Discussion in 'Multiplayer' started by ChrisBannoura, Jun 19, 2018.

  1. ChrisBannoura

    ChrisBannoura

    Joined:
    Feb 19, 2018
    Posts:
    21
    Hello Unity Fans! I was following the Brackeys FPS multiplayer tutorial and I stopped at episode eight
    (Re-spawning). Then, back at Episode 18, where he started setting up a hosting/joining system, it wasn't what I was looking for. So, I tried to create my own function where when one player pressed "Find Match," then a variable would be added one from the server, then player 2 would come along and also press "Find Match," and add one to the variable and once the variable equaled 2, then the Network Manager would create a match that those two players would automatically join. I then realized that this method doesn't work because the server hasn't actually started yet, therefore, cannot access different players and their variables. I have been researching this method for 3 days now, but cant find anything. If someone could explain a method with code on how to do this, I will give credit to them in the game credits for helping with scripting, or with any tutorial out there that does what I ask.

    Thanks in advance!
    -CB
     
  2. ChrisBannoura

    ChrisBannoura

    Joined:
    Feb 19, 2018
    Posts:
    21
    Does anyone know the solution???
     
  3. dmitryon

    dmitryon

    Joined:
    Jan 6, 2018
    Posts:
    9
    I would do it with PHP+MySQL solution.
    Create a table of servers.
    Create PHP scripts to fetch servers list get_servers.php.
    Create PHP script that edits number of available slots on the server connect.php.
    Create PHP script that ends the server end_server.php.
    Create PHP script that starts a server start_server.php.

    Try to connect to the server ip of the latest server which has available slots.
    If connection is established - send connected report in POST parameter of connect.php.
    If failed to connect - send failure report to connect.php and try the next server.
    If there are no more available servers - initialize server and call start_server.php.
    When you want to quit and you are the server - kill the server and call end_server.php.
    If you are client and a server dies - get_servers.php and try to connect to a new server/create a new one.
    It makes sense to only select one of the clients of the disconnected server to become a new server and automatically join the rest of the clients, so the process can be resumed even if server machine drops out.