- Home /
How do re-randomize Random.seed after setting it?
After setting Random.seed to generate content based on the seed, how can I randomly reset the seed to generate a second layer of content that ISN'T based on that seed?
I know I could probably get the system time somehow and use that, but if there's some easier way I'd like to know.
Answer by tanoshimi · Jul 15, 2016 at 07:26 PM
 Random.seed = System.Environment.TickCount;
Should be pretty random....
i used Time.time ins$$anonymous$$d but yeah basically it was already really simple.
Answer by happymoep · May 22, 2020 at 11:26 AM
If you simply want to return Random to how it was before you selected a specific seed I suggest doing something like this:
 // Store current state of the RNG
 Random.State originalRandomState = Random.state;
 
 // Use a specific seed to get the same outcome every time
 Random.InitState(specificSeed);
 // Grab random numbers as you like
 for (int i = 0; i < 1000; i++) {
     GenerateContentFromNumber(Random.value);
 };
 
 // Return the RNG to how it was before
 Random.state = originalRandomState;
Answer by Setsuki · Jun 23, 2020 at 09:03 AM
Reset the seed to a random value.
Since Random.Range will not give you a "random" value, use System.Random.
 //get a randomizer
 var randomizer = new System.Random();
 
 //get a random int seed
 int seed = randomizer.Next(int.MinValue,int.MaxValue);
 
 //set Unity's randomizer to that seed
 UnityEngine.Random.InitState(seed);
Your answer
 
 
             Follow this Question
Related Questions
How to change perlin noise seed? 1 Answer
Generate new blocks to land on 1 Answer
Why aren't my random numbers random? 1 Answer
How to save a random seed to a playerpref 2 Answers
Generating a word out of an array, each has its own rarity. 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                