M2H tutorial Question

Hi.

I’ve never worked with networking before, so I’m pretty much in the learning phase.

I was getting trough the M2H tutorial, everything is clear as daylight, but there was too confusing :

      if (Network.peerType == NetworkPeerType.Connecting){
		
			GUILayout.Label("Connection status: Connecting");
			
		} else if (Network.peerType == NetworkPeerType.Client){
			
			GUILayout.Label("Connection status: Client!");
			GUILayout.Label("Ping to server: "+Network.GetAveragePing(              Network.connections[0] ) );		
			
		} else if (Network.peerType == NetworkPeerType.Server){
			
			GUILayout.Label("Connection status: Server!");
			GUILayout.Label("Connections: "+Network.connections.length);
			if(Network.connections.length>=1){
				GUILayout.Label("Ping to first player: "+Network.GetAveragePing(  Network.connections[0] ) );
			}			
		}

This comes from the connect script included in the tutorial.

Anyway - I find it rather confusing - how come both Ping to Server AND Ping to first Player, work with Network.GetAveragePing(Network.connections[0]) ?

-Jedy

just a guess but they are both considered as players and show up in the connections list.

simple: connections contains the connections to all others.

if you are server → connections[0] = 1st player (as he is the server himself and won’t appear in connections)
if you are a player → connections[0] = server

Considered that, but it sounded way too simple ^^.

Thanks!

-Jedy