Hello,
I’m working now for a few months in Unity and started a new project for a network/online game. I used the tutorial of M2H, and used a script of one of the example’s and changed it a little bit and then builded it. Tested it with with a friend over the internet and it worked.
I decided to expand it a little with a nice menu. builded it again, tested it over internet but now i’m getting an error :
A client which was not in the connected player list disconnected. ???
So i had a connection but disconnected immediately? i couldn’t find anything that was cousing this error so i deleted all script exept the one that worked in the beginning tryed to build it and do it over internet but same error did it local but same error even in a new project with same starting script i’m getting this error and now even my other project (not over internet) gets this error?
I can’t find anything helpfull on the internet so if you could help.
The code that I am using :
#pragma strict
#pragma implicit
#pragma downcast
var connectToIP : String = "127.0.0.1";
var connectPort : int = 25001;
var ConnectPassword : String = "";
function OnGUI ()
{
if (Network.peerType == NetworkPeerType.Disconnected){//hierdoor zie je dat je disconnected bent
GUILayout.Label("Connection status: Disconnected");//hierdoor zie je dat je disconnected bent
connectToIP = GUILayout.TextField(connectToIP, GUILayout.MinWidth(100)); // ip invullen
connectPort = parseInt(GUILayout.TextField(connectPort.ToString())); // port invullen
ConnectPassword = GUILayout.TextField(ConnectPassword, GUILayout.MinWidth(200));
GUILayout.BeginVertical();
if (GUILayout.Button ("Connect as client")) {//zorgt er voor dat je met de server connect
Network.Connect(connectToIP, connectPort, ConnectPassword);} //connect met ingevulde ip en port
//, ConnectPassword
if (GUILayout.Button ("Start Server")){
Network.incomingPassword = "HolyMoly";
Network.InitializeServer(32, connectPort,false);}
GUILayout.EndVertical();
}else{//probeert connectie te maken
if (Network.peerType == NetworkPeerType.Connecting){
GUILayout.Label("Connection status: Connecting");
// geconnected als client
} else if (Network.peerType == NetworkPeerType.Client){
GUILayout.Label("Connection status: Client!");
GUILayout.Label("Ping to server: "+Network.GetAveragePing( Network.connections[0] ) );
//je bent de server
} else if (Network.peerType == NetworkPeerType.Server){
GUILayout.Label("Connection status: Server!");
GUILayout.Label("Connections: "+Network.connections.length);
if(Network.connections.length>=1){
GUILayout.Label("Ping to first player: "+Network.GetAveragePing( Network.connections[0] ) );
}
}
if (GUILayout.Button ("Disconnect")){
Network.Disconnect(200);}
}
}
Thanks,
Ruben,