I was grueling over the exact same problem, and JUST thought of this- It's working out for me, I hope it helps you too-
The problem is that we want to begin at one of any specific points. We were looking at it in a dead end way though. When you load a level, you usually have one spawn point with code to 'JUST START HERE'. We need be able to carry on info from the last level to tell the new level that you want to start at ANY specific point you specify.
I think Bunny83 just descirbed this but I don't understand all that :p...
I thought this could be done with a kind of scoring method that all spawn points could look at. This could done in a much simpler way, so fix it up how you want
Make 3 (or however many) spawn points you want in your levels and tag them startpoint1, startpoint2, etc, and add something like this to them ( I used empty game objects)
function Start() {
if(Player.teleporter == 1){
start1();
}if(Player.teleporter == 2){
start2();
}if(Player.teleporter == 3){
start3();
}
}
function start1(){
var Player = GameObject.Find("Player");
var startpoint1 = GameObject.FindWithTag("startpoint1").transform;
Player.transform.position = startpoint1.position;
}
function start2(){
var Player = GameObject.Find("Player");
var startpoint2 = GameObject.FindWithTag("startpoint2").transform;
Player.transform.position = startpoint2.position;
}
function start3(){
var Player = GameObject.Find("Player");
var startpoint3 = GameObject.FindWithTag("startpoint3").transform;
Player.transform.position = startpoint3.position;
}
Have the actual 'teleporting game object' (a door, a floor pad, something) and add a collider set as a trigger and add this
function OnTriggerEnter(other : Collider) {
Player.teleporter = 2; // whatever number to correspond to where you want to spawn
Application.LoadLevel("cave");
}
on the player's script add this in the update function
DontDestroyOnLoad (this);
and add at the top of the script
static var teleporter = 0;
Do you get the set up? When you hit the exit or 'teleporting game object', you set the players teleporter number to the specifically numbered spawn point you set in the new level.
You'll have to make multiple application.Loadlevel scripts to set the specific numbers, but it works in the long run.