Taken from the Scripting Overview:
// Loads a random level from the level list
Application.LoadLevel(Random.Range(0, Application.levelCount));
If I had for example 10 levels, how would I load a random level between levels 2,3,6 and 9?
Taken from the Scripting Overview:
// Loads a random level from the level list
Application.LoadLevel(Random.Range(0, Application.levelCount));
If I had for example 10 levels, how would I load a random level between levels 2,3,6 and 9?
Put the specific group of numbers you want to choose randomly from in an ordered list, choose a random item from that ordered list, load the level.
int[] randomLevels = new int[] {2, 3, 6, 9};
Application.LoadLevel(randomLevels[Random.Range(0, randomLevels.Length)]);
Try :
int[] MyLevelsToLoad = new int[] { 2, 3, 6, 9 };
int RandomLevelIndex = (int) Math.Min( MyLevelsToLoad.Length-1, Random.Range( 0, MyLevelsToLoad.Length ) );
Application.LoadLevel( RandomLevelIndex );