- Home /
Question by
spiralfire11 · Sep 10, 2013 at 12:08 AM ·
networkingmultiplayernetworkserveronline
My network server doesn't work.
I use this code to build a server and go on it, but I don't know a code for the player and the one for the network doesn't work. Any help?
var IPServer = "127.0.0.1";
var IPServ = "";
function OnGUI (){
if (Network.peerType == NetworkPeerType.Disconnected){
IPServer = GUI.TextField(new Rect(120,10,100,20),IPServer);
if (GUI.Button (new Rect(10,10,100,30),"Connect")){
Network.Connect(IPServer, 25000);
}
if (GUI.Button (new Rect(10,50,100,30),"Start Server")){
Network.InitializeServer(50, 25000,false);
for (var go : GameObject in FindObjectsOfType(GameObject)){
go.SendMessage("OnLoaded", SendMessageOptions.DontRequireReceiver);
}
}
}
else{
if(Network.isServer){
IPServ = Network.player.ipAddress;
GUI.Label(new Rect(140,20,250,40),"IP to be used: "+IPServ );
}
if (GUI.Button (new Rect(10,10,100,30),"Exit")){
if(Network.isServer){
networkView.RPC("ExitCL", RPCMode.Others);
}
Network.Disconnect();
}
}
}
function OnConnectedToServer() {
for (var go : GameObject in FindObjectsOfType(GameObject))
go.SendMessage("OnLoaded", SendMessageOptions.DontRequireReceiver);
}
Comment
You really should post the code in a code sample. There's a button just above the comment window that says "101010", paste code into that as it's hard to read without it.
also please indent the code. It's completely unreadable. Why does it stop at @RPC?
How does this not work? What errors are you getting? Why stop at @RPC?
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Popular Multiplayer Framework/Services? 0 Answers
Making own server instead of using unity matchmaking and relay servers? 1 Answer
Is the master server down? 0 Answers
Networking for 1v1 rooms 0 Answers