- Home /
Question by
RumplyThrower · Jun 17, 2013 at 09:14 PM ·
networkingmultiplayerserverclientconnect
Help with multiplayer connection
Hi, i made a simple client-server based "game" but i'm having trouble connecting to the server over the internet, even though i can connect localy(got problems here aswell but anyway...). Here is my script:
#pragma strict
var IP = "127.0.0.1";
var port = 25566;
function OnGUI()
{
if(Network.peerType == NetworkPeerType.Disconnected)
{
IP = GUI.TextField(Rect(5,65,100,30),IP.ToString());
if(GUI.Button(Rect(5,5,100,30), "Start"))
{
Network.InitializeServer(32,port);
}
if(GUI.Button(Rect(5,35,100,30), "Connect"))
{
Network.Connect(IP,port);
}
}
else
{
if(Network.peerType == NetworkPeerType.Client)
{
Application.LoadLevel(1);
}
if(Network.peerType == NetworkPeerType.Server)
{
GUI.Label(Rect(5,5,100,25), "Server");
GUI.Label(Rect(5,30,100,25), "Users: " + Network.connections.Length);
if(GUI.Button(Rect(5,55,100,25),"Quit"))
{
Network.Disconnect(100);
}
}
}
}
Comment