Teleporting/application.loadlevel

Hello. I’m making a hobby project in unity and I’v encountered a problem when going from one level to another. Heres a picture that sheds some light on what i mean:

4696-paint_dribble.jpg

Currently i only have 2 scenes; 1) main menu 2) level 1 & 2.

When i start the game through main menu, i get moved to a certain position in lvl 1 after that i can move between 1 and 2 by using trigger on collision+transform.position.
Now I’m trying to expand by making more maps, but putting them into the same scene will generate too much lagg, so i moved the existing lvl 2 into its own scene and put it to use:

var destination :int;

function OnTriggerEnter(other : Collider) {
if (other.tag == “Player”) {
Application.LoadLevel(destination);
}
}

Now comes the actual problem: When i go back into lvl 1 scene i teleport to the original starting location, when i should have teleported outside the entrance of lvl 2 (a cave). So basically i start the level 1 over.

This will become even bigger problem when i start making more maps as seen in the picture. Is there a way to teleport just like using transform.position method except between scenes or a way to use application.loadlevel(4) and add some extra parameters like if last map lvl 3 then instantiate spawnpoint at entrance of lvl 3 of 4th lvl(ugh hard to explain). Or any other ways that would be better that what im thinking of.

Thanx for help, sorry for the rant. :slight_smile:

Imho use a KISS approach (Keep it simple sir ) : have a static variable for the last position on each level, then on the level loading set the position of the player at the last position of the level you are entering.

It’s only 3 floats per level, not a huge overhead, and you will avoid allot of non-transparent behavior.