- Home /
Loadlevel can't see each other.
Me and a friend are working on a game and we made it so when a player succesfully connects to the host it loads a scene. The problem is when we load the scene on 2 different computers we can't see each other like we are suppost to. Everything else works fine. Anybody got a clue why this is happening and is there any function we can add? We use the function Application.LoadLevel and we tried adding Object.DontDestroyOnLoad but we still can't see each other. - Thanks on forehand.
Answer by programmrzinc · Jul 14, 2012 at 09:45 PM
is there code in your level that shows the models?
let me give you a scenario. If you and your friend see each other, add a dime to your pocket. You wont have 20 cents in your pocket just because you started something at the same time.
Answer by JonasrDJ · Jul 14, 2012 at 11:46 PM
I don't think so. This is how our ConnectGui looks like.
//DontDestroyOnLoad(this);
var remoteIP = "83.91.127.166"; var remotePort = 25000; var listenPort = 25001; var remoteGUID = ""; var useNat = false; var playerPrefab : Transform; private var connectionInfo = "";
function OnGUI () { GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Space(10); if (Network.peerType == NetworkPeerType.Disconnected) { useNat = GUILayout.Toggle(useNat, "Use NAT punchthrough"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(10);
GUILayout.BeginVertical(); if (GUILayout.Button ("Connect")) { if (useNat) { if (!remoteGUID) Debug.LogWarning("Invalid GUID given, must be a valid one as reported by Network.player.guid or returned in a HostData struture from the master server"); else Network.Connect(remoteGUID); } else { Network.Connect(remoteIP, remotePort); } } if (GUILayout.Button ("Start Server")) { Network.InitializeServer(32, listenPort, useNat); // Notify our objects that the level and the network is ready for (var go in FindObjectsOfType(GameObject)) go.SendMessage("OnNetworkLoadedLevel", SendMessageOptions.DontRequireReceiver);
} GUILayout.EndVertical(); if (useNat) { remoteGUID = GUILayout.TextField(remoteGUID, GUILayout.MinWidth(145)); } else { remoteIP = GUILayout.TextField(remoteIP, GUILayout.MinWidth(100)); remotePort = parseInt(GUILayout.TextField(remotePort.ToString())); } } else { if (useNat) GUILayout.Label("GUID: " + Network.player.guid + " - "); GUILayout.Label("Local IP/port: " + Network.player.ipAddress + "/" + Network.player.port); GUILayout.Label(" - External IP/port: " + Network.player.externalIP + "/" + Network.player.externalPort); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button ("Disconnect")) Network.Disconnect(200); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); }
function OnServerInitialized() { if (useNat) Debug.Log("==> GUID is " + Network.player.guid + ". Use this on clients to connect with NAT punchthrough."); Debug.Log("==> Local IP/port is " + Network.player.ipAddress + "/" + Network.player.port + ". Use this on clients to connect directly."); }
function OnConnectedToServer() { // Notify our objects that the level and the network is ready for (var go in FindObjectsOfType(GameObject)) go.SendMessage("OnNetworkLoadedLevel", SendMessageOptions.DontRequireReceiver ); Application.LoadLevel ("Scene_02"); ;
}
function OnNetworkLoadedLevel () { Network.Instantiate(playerPrefab, transform.position, transform.rotation, 0); }
function OnDisconnectedFromServer () { if (this.enabled != false) Application.LoadLevel(Application.loadedLevel); else FindObjectOfType(NetworkLevelLoad).OnDisconnectedFromServer(); }
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
If Statement Conditional Not Working 1 Answer
A node in a childnode? 1 Answer
How do I create a pause button? 2 Answers
I do a game for the school 1 Answer