Player spawn with DontDestroy
Posted: Wed Mar 16, 2011 9:46 pm
I am having problems trying to figure this out. I am looking for a script (used for OuterNet) that when a player leaves the star system, they are spawned back on the outside of the star system in the main scene called "Sector 1" and also includes the DontDestroyOnLoad(this) feature. I have 15 star systems in the main scene that will require a spawn point for each star system, and a spawn point inside each star system after entering from the main grid.
Does anyone know how to do this? I'm in need of this. With this the game will have taken a huge step forward so I can start linking the scenes to the main grid and back.
Right now, my script to load the main grid looks like this:
And this is the code I am using for entering the system:
Does anyone know how to do this? I'm in need of this. With this the game will have taken a huge step forward so I can start linking the scenes to the main grid and back.
Right now, my script to load the main grid looks like this:
Code: Select all
function OnTriggerEnter(){
Application.LoadLevel("Sector 1");
}
Code: Select all
var availableLevels : String[];
var windowWidth : int = 200;
var windowHeight : int = 100;
var target : ShipControlScript;
private var showMenu : boolean = false;
function OnTriggerEnter () { //Replace TriggerAction with your desired means of triggering the menu.
target.flyingSpeed = 0; //stops ship in tracks and loads menu
showMenu = true;
}
function OnGUI () {
if (showMenu) {
GUI.Window(0,
Rect((Screen.width / 2) - (windowWidth / 2),
(Screen.height / 2) - (windowHeight / 2),
windowWidth,
windowHeight),
LevelSelect,
"Enter Star System?"); //Creates a window with ID 0 in the center of the screen using the function LevelSelect with the title, "Select a level!"
}
}
function LevelSelect (id : int) {
for (var levelName : String in availableLevels) {
if (GUILayout.Button(levelName)) {
Application.LoadLevel(levelName);
}
}
if (GUILayout.Button("Cancel")) { //Gives the player the opportunity to back out of the menu.
showMenu = false;
}
}