Quantcast
Channel: Answers for "Random.Range always generates the exact same numbers in Start()"
Viewing all articles
Browse latest Browse all 4

Answer by Arycama

0
0
Before calling your Random functions, set the Random.Seed to a number that isn't likely to be the same twice in a row. An easy way to do this would be: Random.seed = System.DateTime.Now.Millisecond; Add this line above your existing code (Before you call Random.value etc), and it will make the values seem much more random, as they would only be the same if you could go back in time and run the program again at the exact same millisecond as before. ;) Think of a random number generator on a computer as a list of seemingly unrelated numbers, derived from a starting number (Called the "seed"). Changing the seed changes the random numbers you'll get. Some random number generators can be more complicated, but in many cases, having a repeatable output from a random number generator is useful, for example in Minecraft, the world seems random, but if you make a new world with the same seed as a previous world, everything will be generated exactly the same.

Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images