- Home /
random level loader?
i already have a game set up and ready to be played, but i have one problem.
the character starts in a small room, and when they exit through a door, it should take them to 1 of 12 different level outcomes. i have the level loading script, but i'm not sure how to splice the random generator into the level loader. anyone know how?
function Start() {
number = Random.Range(1,12);
}
function OnCollisionEnter (collision : Collision) {
if (collision.gameObject.name=="Player")
Start();
Application.loadLevel(1);
}
Answer by robertbu · Mar 17, 2013 at 08:00 PM
Application.loadLevel(Random.Range(1,13));
Note that the scripting reference statement for Random.Range() of integers:
Returns a random integer number between min [inclusive] and max [exclusive]
So it will never return the last value in the range.
Your answer
Follow this Question
Related Questions
how to load random level but one? 3 Answers
level loader script wont work 1 Answer
how do you actually stop a game? 3 Answers
Load a scene/level when enemy is close... 1 Answer
Score and Level Loading 1 Answer