x


Help with Connect GUI script from Unity's Example Project

I downloaded Unity3d's Networking Example project and I put out the 3rd person scene online. when me and my friends tried to join it wouldnt connect.please if you have any suggustions. here is code.


//DontDestroyOnLoad(this); var remoteIP = "127.0.0.1"; var remotePort = 25001; var listenPort = 25000; var useNAT = false; var havemaster = false;

function Awake() {

if (havemaster == true){ if (FindObjectOfType(ConnectGuiMasterServer)) this.enabled = false; } }

function OnGUI () { GUILayout.Space(10);

GUILayout.BeginHorizontal();
GUILayout.Space(10);
if (Network.peerType == NetworkPeerType.Disconnected)
{
    GUILayout.BeginVertical();
    if (GUILayout.Button ("Connect"))
    {
        Network.useNat = useNAT;
        Network.Connect(remoteIP, remotePort);
    }
    if (GUILayout.Button ("Start Server"))
    {
        Network.useNat = useNAT;
        Network.InitializeServer(32, listenPort);
        // Notify our objects that the level and the network is ready
        for (var go in FindObjectsOfType(GameObject))
            go.SendMessage("OnNetworkLoadedLevel", SendMessageOptions.DontRequireReceiver);     
    }
    GUILayout.EndVertical();
    remoteIP = GUILayout.TextField(remoteIP, GUILayout.MinWidth(100));
    remotePort = parseInt(GUILayout.TextField(remotePort.ToString()));
}
else
{
    if (GUILayout.Button ("Disconnect"))
    {
        Network.Disconnect(200);
    }
}

GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();

}

function OnConnectedToServer() { // Notify our objects that the level and the network is ready for (var go in FindObjectsOfType(GameObject)) go.SendMessage("OnNetworkLoadedLevel", SendMessageOptions.DontRequireReceiver);
}

function OnDisconnectedFromServer () { if (this.enabled != false) Application.LoadLevel(Application.loadedLevel); else FindObjectOfType(NetworkLevelLoad).OnDisconnectedFromServer(); }_________________________

more ▼

asked Jan 24 '11 at 01:00 AM

gamer gravatar image

gamer
1 2 3 3

wont work for me either

Jan 24 '11 at 01:37 PM gamer
(comments are locked)
10|3000 characters needed characters left

0 answers: sort newest
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x702
x20
x7

asked: Jan 24 '11 at 01:00 AM

Seen: 1076 times

Last Updated: Jan 24 '11 at 01:00 AM