- Home /
Check loaded level if statement
Hey everyone having some issue. Working on my first project, and I need to check the level and if the level = (level number here) I need it to do something.
Code I have now in c# it does not work. Essentially I need something like this. I would like to be able to call this in a trigger event. So if I collect all the coins it will check to see what level it is and if it is "3" then load _Scene.
void CheckLevelReset() {
if (Application.LoadLevel (3))
Application.LoadLevel("_Scene");
}
Answer by robertbu · Mar 02, 2014 at 05:29 AM
You are looking for Application.loadedLevel or possibly Application.loadedLevelName:
void CheckLevelReset() {
if (Application.loadedLevel == 3)
Application.LoadLevel("_Scene");
}
$$anonymous$$y bad. I fixed my code. Your solutions works. I did not notice the difference in yours of "Loadedlevel" rather than my LoadLevel.
Thanks for the help! Can't upvote you because I don't have enough rep sadly D:
Your answer
Follow this Question
Related Questions
Help with input code please (c#) 1 Answer
Show Button to LoadLevel After Collecting # of Points 1 Answer
How do I stop the scene from switching when the gameObject is destroy / 0 Answers
Load a new level after objects have been collected 2 Answers
Keeping objects destroyed during runtime of the game 1 Answer