I am doing some randomly generated things in my game and just wondered why a random integer (using the "SetVariable" action) with parameters "0 to 1" always returns 0. I found out that AC uses the Unity method "Random.Range" which excludes the "max" value. E.g. a max value of 10 given in the action will return numbers from 0 to 9. This should be mentioned somewhere or even better AC should work with an "entered value+1" when generating the random integer.
From the Unity scripting API:
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.
Comments
I added 1 to all max values in game now and it works. But I think it should be mentioned in the manual or added by 1 internally by AC when working with integers because otherwise it can lead to unnecessary bug hunting like in my case.