- Home /
How do I end my level?
I am making a 2d sidescroller which has a terrain/sky looper so it duplicates everything. The problem is when I reach a certain point, say a sign in the ground I would like that to be the end of the level and level 2 be loaded. I have no idea how to do this. I have searched for several days looking for something that relates to my project but cant find anything.
I had considered taking the looper out and just making the whole level but would still run into the problem of not knowing how to end the level and load the next scene. I figure you would have to click a button whether IOS, Android, or pc before the level started as I know I would be annoyed if it just started without warning.
If anyone could shed some light on this for me I would greatly appreciate it.
If I wasnt specific enough please let me know and I will try to answer your questions as best I can. This would be my first Unity game once done.
Enter a trigger collider at the end of the level
This brings up a gui message and a button "End of Level! Proceed?"
user clicks button, Application.LoadLevel
For an infinite looping level you could use a timer to trigger the end.
Answer by Maskerov · May 15, 2014 at 07:03 PM
I think it can also be used coordinates so when the character passes a possition, you load the next scene. However, using invisible cubes or planes are also good ways to do it.
Answer by MrBearHat · Sep 19, 2014 at 09:12 AM
ok here is the simple way make a cube (make sure it aligns with the player or it wont work) turn of the mesh renderer for the cube then you need a script here is the javascript to do it
#pragma strict
var Level = "";
function OnTriggerEnter(other : Collider){
if(other.tag == "Player"){
Application.LoadLevel(Level);
}
}
and add it to the cube then enter the level to load in the components of the cube
and when you hit the cube you will be put in the next level/scene
NOTE: make sure your scene/level is added to your build settings. Also make sure that your player has the tag Player