![]() maybe you use coroutines to generate a couple tiles per frame. And another does it between the 7 and 10 (this might happen just due to bad design. So what if one machine generates this random position between the 3 and 4 tile generation. Now in Unity, depending how you set up scripts, the order of these scripts may or may not be guaranteed from system to system. Problem arises if in the middle of that sequence some other piece of code ALSO calls Next to generate some other thing. if I generate 10 random tiles as 10 calls to Random.Next (or ), the 10 tiles in a row will be generate via the same sequence of numbers. if I seed a Random with some value, I'm guaranteed the SAME sequence. This is what I mean by "sequence of calls". This value is called the 'seed'.Įvery time you call 'Next' it performs this algorithm on the last generated value (or seed if it's the first call) to get the next value. This means that the sequence must have a FIRST value. This means that every value in the sequence is dependent on the previous value. ![]() ![]() A float/double between 0->1 is calculated merely as that value in the sequence divided by Int.MaxValue. In the case of System.Random it's a value from 0 to Int.MaxValue. How random number generators work, it uses a special algorithm (like a Mersenne Twister) that generates a value from the previous value that has equal odds across the entire range of values that can be returned. With that said, whenever you call any of the methods that get random values on UnityEngine.Random, it is like calling. Click to expand.So, I'm going to describe this with System.Random instead of UnityEngine.Random, becuase it's interface is better at describing what's going on.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |