How to increase chances of the last value of a random range?

When you used “Random.Range ( 0, anIntNumber)”, did you notice that the last value in this range is very rare to occur. However, I need it to happen more often than other values. How can I change the occurring chances on this specific value?

Actually it will never return the second parameter. Random.Range with integers excludes the second parameter.

With floats the second parameter is included in the range

Random.Range in API docs

If you need the last parameter to be included in the results, you just have to increase the range by 1.

If you need a specific value to occurr even more often, there’s no shortcut. You just have to resort to old school math. For example

var random = Random.Range(0, 5 + 1); // 0 to 5

var random1 = Random.Range(0, 5 + 2);
if (random1 > 5)
    random1 = 5;
// 6 possible values, 2 of which are '5'