Random Range Variable

Well I couldn’t seem to google an answer, so I will ask it here.

I have a temperature system in my game and I am looking to add or subtract a certain amount of degrees after a certain amount of time. So, I used InvokeRepeating and set it to 60 seconds…

All of that is done, I have also assigned a variable to an int.

So here is what I have.

Top of Script.

public var TempChangeAmount : int;

Start Function.

TempChangeAmount = (Random.Range(-3,3));

Temperature Management Function (Repeats Every 60 Seconds.)

Temp += TempChangeAmount;

My problem is that no matter what, Temperature is always subtracted by 3 instead of a random number through 3 or -3.

Thanks.

public var tempChangeAmount : int;
function Awake()
{
       tempChangeAmount = GetWeatherChange();
}

function GetWeatherChange() : int
{
    return Random.Range(-3, 3);
}

Thank you. I appreciate it.

Random.Range(-3, 3) won’t return -3 to 3, though, since it’s non-inclusive when used with integers.

–Eric