I want to make this (C#) script that generates a random number between a minimum and maximum value and then when you press a button I want it to generate a new random number, but before it generates it I want it to check the new number so I can check if the new number is higher or lower than the old number.
I have a minimum and maximum value (integers) and I have the random number (int currentNumber). Each time I click the button it changes the currentNumber to another random number (random.range(min, max)). But how do I check the new number so I can tell if it’s higher or lower? (It’s for a game where you have to guess if the next number will be higher or lower than the current number you are seeing, so you have two buttons, higher and lower and you press the one you think it’ll be)
You just need another variable called oldNumber
public void MakeNewNumber()
{
oldNumber = currentNumber;
currentNumber = Random.Range(minValue,maxValue);
if (currentNumber > oldNumber)
// Do greater stuff
else if (currentNumber < oldNumber)
// Do less than stuff
else
// Do Equals stuff
}
Thank you so much! ![]()