# Random Numbers... Again

 0 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. more ▼ asked Jul 28 '10 at 03:07 AM e.bonneville 5.7k ● 100 ● 116 ● 165 SisterKy 2.4k ● 33 ● 41 ● 59 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 ``````function Start () { var number1 = Random.value; var number2 = Random.value; Debug.Log (number1 + " " + number2); } `````` The only reason to set the seed is if you want a repeating sequence of numbers. more ▼ answered Jul 28 '10 at 03:18 AM Eric5h5 80.2k ● 41 ● 132 ● 519 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 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users
 0 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. more ▼ answered Jul 28 '10 at 05:26 AM Ashkan_gc 9.1k ● 33 ● 56 ● 117 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 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email: