- Home /
Question by
spiralfire11 · Sep 17, 2013 at 09:26 PM ·
networkingmultiplayerclient
Network Multiplayer
I don't know how to make a script for an second person who wants to join my network and view the game the same as mine. I only have the network script, but not the client. And on what do I attache the client script? This is the network script:
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
Your answer
![](https://koobas.hobune.stream/wayback/20220613114349im_/https://answers.unity.com/themes/thub/images/avi.jpg)