Random number is always the same

The problem is this: I need to get a random number in a certain interval (For example, between the numbers 10 and 20). The problem is that I always get the smallest number and I don’t know what the problem is! Thanks to everyone who helps!

Here is the code: int _randomInt = Random.Range(_intMin, _intMax);
The number must be “Int”.

The only way that Random.Range would give you the same number everytime is if your _intMin and _intMax numbers were set to the same value.


They might repeat a value for a period because


1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 3, 5, 3, 1


Could still be a random sequence. If you want a unique number every time then firstly, it wont be random and secondly just store the last number and programatically re-roll until its different.

Alternatively use System.Random:

System.Random rnd = new System.Random();
int _randomInt = rnd.Next(10, 21); 

max value is exclusive like in Unity’s Random.Range

Is this problem happening on a specific platform?