Why does Random.Range () return the same number?
Every time it returns 0.
Instantiate (Object [Random.range (0, 1)], new vector2 (0, 0), quaternion. Identity);
Answer 1, Authority 100%
To get random zeros and units, you need to call:
random.range (0, 2) // Integers in Range [0, 2)
In integer overload Random.Range MAX is excluded:
Public Static Int Range (Int Min, Int Max);
Description :
RETURN A RANDOM INTEGER NUMBER BETWEEN MIN [INCLUSIVE] AND MAX [EXCLUSIVE]Note Max Is Exclusive. Random.Range (0, 10) CAN RETURN A VALUE BETWEEN
0 and 9. Return min if Max Equals min.
Description :
Returns a random integer between MIN [inclusive] and max [exclusively]ATTENTION : MAX does not turn on.
Random.Range (0, 10)
can return values from 0 to 9. Returns min if MAX is min.
So, you need Random.Range (0, 2)
Overload for valid numbers, on the contrary, includes both end of the interval.
Answer 2, Authority 33%
Supplement if you need from 0.5F and up to 4 here’s an example.
random.range (.05f, 4);