Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Network.connections... what happens if a connection is lost?

Discussion in 'Multiplayer' started by yoonitee, Apr 16, 2014.

  1. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    2,363
    A quick question.

    If 5 players are connected to a server and the 3rd loses his connection, what happens to the Network.connections array?

    Is the 3rd value removed and the rest drop down?

    In which case Network.connections[5].ToString() for connection "5" would change to "4"?

    Or is it safe to use Network.connections[5].ToString() to identify each separate machine?

    Then if a new connection is made after one drops out, is this one added to the end of the array or fills the place left by the previous connection? In which case we would have the same ID but the machine has changed.
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    In Unity, one player's machine is the host. This is actually the server for your game and all others connect to that.
    If this host drops (crash, network loss), then the game is lost and all drop. This can be a real problem in games with more than 2 players (cause when the host drops, it gives the other 3 players the impression that multiplayer won't work).

    Any other player can drop out of the game and won't end it.
    Unless you code it to end when a player dropped.