|
How can I generate two different random numbers in Unity at the same time without using time as the seed for the generator? Thanks in advance - Elliot B.
(comments are locked)
|
The only reason to set the seed is if you want a repeating sequence of numbers. Thanks, but won't number 1 and number 2 be the same?
Jul 28 '10 at 01:25 PM
e.bonneville
@Elliot Bonneville, of course not, or I wouldn't have posted that. It takes about 2 seconds to try it, you know. ;) (Well...they might be the same by random chance, but it's pretty unlikely.)
Jul 28 '10 at 07:45 PM
Eric5h5
(comments are locked)
|
|
seeds will help you to generate different sequence of numbers. the random functions are not really random and they use an algorithm to do their job. seed is the number that is the input of the random function and will lead to different sequences. don't change your seed when debugging but when you are sure that the code is working great. then use DateTime.now or ... to make it really random. so with one seed, each time when you call random you will get a different value but in multiple game sessions, you will get always those same random numbers. the sequence of numbers will be the same. You only need to set Random.seed if you specifically want a repeatable set of "random" numbers. Otherwise just leave it alone. Priming Random.seed with DateTime.Now is unnecessary, since the Random class already does that (or something like it) for you, as long as you don't touch Random.seed in the first place.
Jul 28 '10 at 05:47 AM
Eric5h5
(comments are locked)
|
