0
Unity Shuffle Scenes without Repeating
How can I randomize scenes without repeating the same scene ? Example: I have 5 scenes, 1 is for Level Select and other 4 is for Levels. What I'm trying to achieve is 1st is the randomize scene without repeating and 2nd is if I get to the last scene of Levels, if I click the "next" button, it will go to the Level Select scene. TIA
4 odpowiedzi
+ 2
use a shuffling algorithm, for example this
int n = 4;
while (n > 1)
{
n--;
int k = rng.Next(n + 1);
int value = list[k];
list[k] = list[n];
list[n] = value;
}
+ 1
Make an array 1,2,3,4 (or 2,3,4,5 if that's better)
shuffle it, then for each number in this array show the corresponding level/scene, after the last number in the element show the level select scene.
0
How can I shuffle it without repeating ?
0
Thanks thanks, I'll try.