- Home /
Network - Best Way To View Players In Game?
Hello,
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!
Answer by whydoidoit · May 25, 2012 at 10:43 PM
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). http://answers.unity3d.com/questions/256458/adding-functions-variables-to-runtime-classes.html
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.
Ah $$anonymous$$ike saves the day once again! I like the idea of having a common name generator, good idea! Thanks again!
Oh and I tend to add the name of the player floating over their head the first time you see them, fade it out after a couple of seconds. Note that's see them, i.e. in view for more than 0.5 seconds on the particular players view.
You can also popup "toast" in a corner of the screen when a player joins or leaves - that's quite nice. Also cool for things like "Bill just blasted Bobby" etc
Gives them all personality even if you can't see them if you do funny stuff like - Bill just ran into a wall! - Well I find it funny ;)
Hey your networking questions are doing my $$anonymous$$arma no end of good :)
Your answer
Follow this Question
Related Questions
object naming via network 0 Answers
MMO Player Hosting 0 Answers
UNet, how to create Internet game (like via PhotonNetwork) 0 Answers
Displaying players name above in multiplayer 1 Answer
A name For the Character Please Help 3 Answers