Question by
Crossroad1000 · Sep 05, 2016 at 03:31 PM ·
serverconnectionconnectipcannot
Can't connect to server
Hi, I made a script so I can connect 2 computers that have the same ip address. It works on one computer but the other computer with the same ip won't connect.
Here is the script:
public string IP = "127.0.0.1";
public int Port = 16900;
public GameObject target;
void OnGUI()
{
if(Network.peerType == NetworkPeerType.Disconnected)
{
if(GUI.Button(new Rect(100,100,100,25),"Start Client"))
{
Network.Connect(IP,Port);
}
if(GUI.Button(new Rect(100,125,100,25),"Start Server"))
{
Network.InitializeServer(10,Port);
}
}
else {
if(Network.peerType == NetworkPeerType.Client)
{
GUI.Label(new Rect(100,100,100,25),"Client");
if(GUI.Button(new Rect(100,150,110,25),"Logout"))
{
Network.Disconnect(250);
}
}
if(Network.peerType == NetworkPeerType.Server)
{
GUI.Label(new Rect(100,100,100,25),"Server");
GUI.Label(new Rect(100,125,100,25),"Connections: " + Network.connections.Length);
if(GUI.Button(new Rect(100,175,100,25),"Logout"))
{
Network.Disconnect(250);
}
if(GUI.Button(new Rect(100,150,110,25),"Change Color"))
{
GetComponent<NetworkView>().RPC ("ChangeColor", RPCMode.All);
}
}
}
}
[RPC]
void ChangeColor()
{
Application.LoadLevel("Startvideo");
}
}
Comment