- Home /
How to load next scene on collision ?
Because my project have lots of scenes ,making unique scripts for every scene,each with a level string, will make a lot of trouble,i'm trying to make a generic prefab that just load the next or last scene on collision,just based in the current scene,something like :
scenes []
s1 s2 s3 s4 etc
on triggerenter Application.LoadLevel(current scene +1)
on triggerenter Application.LoadLevel(1/2/3/4); ? Is that something that you want?
Answer by Berenger · May 11, 2012 at 03:24 AM
if( Application.loadedLevel + 1 < Application.levelCount )
Application.LoadLevel( Application.loadedLevel + 1 );
Answer by zero84085 · Jul 18, 2012 at 07:42 AM
function OnTriggerEnter(){
Application.loadlevel(1)
}
make a object and remove the tick from mesh rendeerer after that be sure your object have collider and is set up trigger , when player enter the invisible object the level you want get load (1) sorry for my bad English
Answer by buFFalo94 · Feb 06, 2016 at 02:25 PM
try to rearrange your scene in your build setting like that
so with that you can load your level easily with Application.LoadLevel(current + 1); or current - 1 you also fetch the loaded level using Application.loadedLevel if your using unity 5.3 use [SceneManager][1] insert 'using UnityEngine.SceneManagement' at the top of your scrip [1]: http://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.htmlscene 1: index will be 0 scene 2: index will be 1 and so on...
Your answer
Follow this Question
Related Questions
Open door = load scene c# issues 4 Answers
Change scene with trigger collision not working. 1 Answer
Closed - Go to next scene on collision 1 Answer
Scene Change Collision 2 Answers
OnTriggerEnter Collision 1 Answer