Network - Best Way To View Players In Game?


Just wondering whats the best approach to viewing all the players currently in my networked game? For example, if I press the ‘s’ key and a table comes up showing all the players currently in game?

Right now the players are defined by ‘Network.player’, which just shows an int, so I’m thinking before the player joins, he/she types a player name into a GUI.Textfield, which is then passed on to the game, and held into an array that the ‘Network.player’ can be used as an index?

I’m hoping, at a later stage, to hold a score too, which will be displayed in the table next to the players name.

Could this work, is there a better way to do this? Could you show me some examples?

Thanks all!

Firstly you can use the code in my second example on the post I’m linking to in order to hold variables indexed off Network.player without worrying about reference counting and deleting them afterwards (avoids memory leaks etc). Modifying a prototype in UnityScript - Questions & Answers - Unity Discussions

That code will let you hold a name, a score and anything else you want.

If you don’t want to slow down your player you could just assign them a random name (made from common name parts) and give them the ability to overwrite it.