- Home /
 
               Question by 
               Anymeese · Aug 21, 2014 at 02:17 AM · 
                networkingmultiplayeronlinehostjoin  
              
 
              Unity networking: how to detect when a user joins the server you are hosting?
Right now I have a Host Game button and a Join Game button. When you click the Host Game button, it shows a window saying "waiting for player to join." When you click the Join Game button, it shows a window showing active games, and updates the list every couple seconds.
Obviously I can see when the JOINING player joins the game (and therefore load the gameplay scene), but how can I detect when that happens as the HOSTING player?
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by TwisterK · Aug 21, 2014 at 02:28 AM
http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnPlayerConnected.html
In the mono script, type something like this, it will be called whenever a player had join the server. This is C# version.
 void OnPlayerConnected(NetworkPlayer player) {
         Debug.Log("Player " + playerCount + " connected from " + player.ipAddress + ":" + player.port);
     }
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                