+ 3
Random.Range
if i set mindrop to 0 and maxdrop to 3. if i do. int dropamount = random.range(mindrop,maxdrop) i always get 0 1 or 2 as result. what am i doing wrong
4 Answers
+ 4
maxdrop is exclusive.
https://docs.unity3d.com/ScriptReference/Random.Range.html
public static int Range(int min, int max);
Description
Returns a random integer number between min [inclusive] and max [exclusive] (Read Only).
Note that max is exclusive, so using Random.Range( 0, 10 ) will return values between 0 and 9. If max equals min, min will be returned.
+ 7
If you are looking for a whole number from 0 to 3 (inclusive), increase the maxDrop by 1.
Random.Range(minDrop, maxDrop + 1);
As @sneeze explains, you need to do this because maxDrop is exclusive.
+ 2
cheers both
0
try this,
int dropamount=random.range(mindrop,maxdrop+1);