Hey all
I’m kinda new with all this Server-Client programming, so I followed some tutorials which gave me a basic idea of how to make it work, but now I have this really annoying problem
When I click a login button, it should run my Network.Connect(“127.0.0.1”, 2602);
After this I should be online with my client, which is true, because I check for connections on my Server which tells me that I have one signed on, but the wierd thing is that when I print(Network.peerType);
I’m given Disconnected, even though my Server says I’m connected.
Next time I click the login button, it tells me I’m Client
Might it be because of my code that takes too much time to run?
function OnGUI(){
if(!loggedIn){
if(!registering){
GUI.BeginGroup(new Rect(Screen.width/2 - 300, Screen.height/2 - 300, 600, 600));
GUI.Box(new Rect(0,0,600,600),"Gladiator Wars");
username = GUI.TextArea(new Rect(200,50,200,25),username);
password = GUI.TextArea(new Rect(200,75,200,25),password);
if(GUI.Button(new Rect(200,100,200,25), "Login")){
Connect();
print(Network.peerType);
}
}
}
}
function Connect(){
if(Network.peerType == NetworkPeerType.Disconnected){
Network.Connect("127.0.0.1", 2602);
}
if(Network.peerType == NetworkPeerType.Client){
networkView.RPC("Login", RPCMode.Server, username, password, Network.player);
}
print(Network.peerType);
}