I have a problem when Using Random.Range(); (C#) where it never returns the max number.
i.e. if I define Random.Range(1,3); it will NEVER return 3. Why is this? and how can I make things a bit more random in my game?
Thanks for the help
I have a problem when Using Random.Range(); (C#) where it never returns the max number.
i.e. if I define Random.Range(1,3); it will NEVER return 3. Why is this? and how can I make things a bit more random in my game?
Thanks for the help
It will not return the top number if you call it using two integers - that’s because it’s trying to help you out and return a value that is in the bounds of an array or list. If you call it with two floats then it will.
It’s in the documentation that way.
static int Range(int min, int max);
Description
Returns a random integer number between min [inclusive] and max [exclusive] (Read Only).
If max equals min, min will be returned. The returned value will never be max unless min equals max.