Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How Network Decides Host?

Discussion in 'Multiplayer' started by renman3000, Nov 10, 2016.

  1. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,680
    I am creating a game which will be PvP, so, 1 player vs 1 player. So, 2 player max. The game, will randomly match players looking to play.

    What I am wondering is, how the game will determine host and client.

    So, is this a random decsion? Is it the player who looks for a game first? How does it work? How does the network determine, which player is Host and which is Client?

    Thank you
     
  2. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    151
    You decide.
     
  3. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,680
    okkkkkk.

    So, let say me and you decide to play.

    You press play before me. What will happen is a cue to look for other players wanting to play. None exist until I press play. Now that the server sees you and i, it matches us ( I am assuming this is the process (coming from photon)).


    I am not sure if it matters, but then at this point, where two players are assigned to a room, is the host client role decided in the background automatically?

    Perhaps I am not at the point yet where I have come across this in the tutorial.
     
  4. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    151
    In Unet system, client can host.

    If no rooms are availables on matchmaking server (on Unet server) : your first client, who want a room, have to create it.
    It's not "Automatically", you have to see if a room is available and if not : create it and become a host.

    BUT

    Imagine you want to host some rooms(to prevent cheat or whatever) on a professional server. Developer will launch some servers, this servers host the game and your client will connect to them.

    I haven't tried yet the second solution (no money/knowledge for that ^^).
     
  5. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,680
    edit...
    I think I just found what I want, the NetworkLobbyManager.




    //original

    Right, thank you. I actually just started a related thread here....link

    But what I am wondering is how do I a) set the room requirements (number of players), b) know those requirements are met?

    I can not see anything in the official docs.