Network Switching Levels and Keeping track of players

Hey Guys,

I’ve been using unity for a little while now but dont know too much about its networking aspects, Ive managed to write a simple “network manager” script following tutorials and have been wrapping my head around the concepts slowly but I am stuck on switching / loading levels on say… when someone collides with a particular geometry?.. even after extensive google-ing I havent come across any tutorials on this either…

this is the current script for my network manager… any help would be really awesome… cheers peeps!

var playerPrefab: GameObject;
var spawnObject: Transform;

var gameName:String = "Virtual Museum World";

private var refreshing: boolean;
private var hostData: HostData[];

var btnX:float;
var btnY:float;
var btnW:float;
var btnH:float;

function Start(){
btnX = Screen.width*0.2;
btnY = Screen.height*0.2;
btnW = Screen.width*0.2;
btnH = Screen.width*0.05;
}

function startServer(){
Network.InitializeServer(32,25001, !Network.HavePublicAddress);
MasterServer.RegisterHost(gameName,"Virtual Model", "Network Tutorial Environment");
}

function refreshHostList(){
MasterServer.RequestHostList(gameName);
refreshing = true;
}

function Update(){
if(refreshing){
if(MasterServer.PollHostList().Length >0){
refreshing = false;
Debug.Log(MasterServer.PollHostList().Length);
hostData = MasterServer.PollHostList();
}
}
}

function OnServerInitialized(){
Debug.Log("Sever Initialized!");
spawnPlayer();
}

function OnConnectedToServer(){
spawnPlayer();
}

function spawnPlayer(){
Network.Instantiate(playerPrefab, spawnObject.position, Quaternion.identity,0);
} 

function OnMasterServerEvent(mse:MasterServerEvent){
if(mse == MasterServerEvent.RegistrationSucceeded){
Debug.Log("Registered Server!");
}
}

function OnGUI(){

if(!Network.isClient  !Network.isServer){

if(GUI.Button(Rect(btnX,btnY,btnW,btnH), "Start Server")){
Debug.Log("Starting Server!");
startServer();
}
if(GUI.Button(Rect(btnX,btnY+100,btnW,btnH), "Refresh Host")){
Debug.Log("Refreshing!");
refreshHostList();
}
if(hostData){
for(var i:int = 0; i < hostData.length; i++){
if(GUI.Button(Rect(btnX*1.5+btnW,btnY+(btnH*i),btnW,btnH), hostData[i].gameName)){
Network.Connect(hostData[i]);
}
}
}
}
}

this line: Network.InitializeServer(32,25001, !Network.HavePublicAddress); the last part is a function so !Network.HavePublicAdress() you forgot parentesis.

anyhow to keep track of players if you are going to use this same script across levels you don’t want it to destroy on load so you would put that in the awake function. now you would need to learn about classes and array and lists and make it so when you call on server initialized, on player connected and on connected to server to add that player.

on the class you might want to have a networkplayer variable besides the name, the rest would be what you want for example in a fps you would put kills and death and so on.