I am using Network.connections.Length to display the number of players in an online game, but when I start a server (As the server) I am told there are no players in the game, even though I am in it. Is this because Network.connections.Length does not include itself, or is it more likely a problem in my coding?
Network.connections, as the name said, only holds network connections. When the server is alone, he’s not connected to anyone, so the Length is of course “0”. When one player joins there is one connection from this new player to the server. If three clients joined the server there are three connections.
Keep in mind that Network.connections on clients will always be either “0” or “1”, nothing else. A client can only be connected to one server at a time. Network.connections can be used to count the player on the server, but there’s no way to get this information on a client. A client has no idea how many other players are connected to the server. You have to count the players on the server and send this information explicitly (via RPCs) to your clients.