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

31st Aug 2018, 9:39 AM
Mugiwara
Mugiwara - avatar
4 ответов
+ 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; }
31st Aug 2018, 9:53 AM
michal
+ 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.
31st Aug 2018, 9:47 AM
michal
0
How can I shuffle it without repeating ?
31st Aug 2018, 9:50 AM
Mugiwara
Mugiwara - avatar
0
Thanks thanks, I'll try.
31st Aug 2018, 10:00 AM
Mugiwara
Mugiwara - avatar