Hi
i want to make every player that enters the game sends that he entered
and add 1 to players connected
and then i want him to know how many players are connected
the thing is this playersConnected int
should be sent and received but how and from who and where to store it
i can’t figure this at all i 
http://docs.unity3d.com/ScriptReference/Networking.NetworkServer-connections.html
If you want multiple player per connection you should probably keep track of whenever a client Adds or Removes a player.
As I said in your other thread already you should probably have one static server controlled Object that syncs all these global numbers.
NetworkServer is only callable by the server right? So only the server knows the number of players? And it could sync the list out to the clients?
1 Like
You can register all spawned Player and get your list of connected client.
I did that to display some info about the connected players.
@SuperNeon how did you do that?
Hi !
I have a GameManager with a function to register it.
In the callback OnStartClient I call this function.
For exemple:
public class Player
{
void OnStartClient()
{
GameManager.RegisterPlayer(this);
}
}
public class GameManager
{
static List<Player> m_Players = new List<Player>();
public static void RegisterPlayer(Player player)
{
m_Players.Add(player);
}
}
3 Likes