- Home /
How to load next level?
I have this code here:
function Update () {
if(Input.GetKeyDown=="space")
Application.LoadLevel("lvl2");
}
How can i load to the scene "lvl2"? I attached this script to the First Person Controller.
Answer by FLASHDENMARK · May 13, 2012 at 07:04 PM
As Bérenger said make sure to have the level "lvl2" added in the build settings.
Normally you would detect input like this and not like you did:
function Update () {
if(Input.GetKeyDown("space"))
Application.LoadLevel("lvl2");
}
Give this a try and see if that fixes anything.
Answer by Berenger · May 13, 2012 at 06:13 PM
By pressing space. Make sure you actually have a scene called lvl2 added to the build.
good one... but it does not work, also i have the scene named lvl2
Add a print before the LoadLevel to make sure the input is detected. Go in file->Build Settings and make sure lvl2 is added in the "Scene in Build" part. If it still doesn't work, use the id ins$$anonymous$$d. If it still doesn't work, something is wrong with the matrix.
Your answer
Follow this Question
Related Questions
heavy scene loading 1 Answer
Save & Load Game question 3 Answers
LoadSceneMode.Single seems to be not working. 0 Answers
Unloading a loaded Scene when load Async for a Loading Bar 1 Answer
Random level select 1 Answer