Hi,
I’m trying to get into scripting for Unity with a fairly simple project, and I’m running into trouble with Random.Range.
I’d like to get a random value each time I press a button (for now at least).
However, it seems like each value is only generated once.
function Update()
{
if(Input.anyKeyDown)
{
RollTheDice();
}
}
function RollTheDice() {
var value = Random.Range(1,7);
print(value);
}
If I press any key after all numbers from 1 to 6 have been printed out, nothing happens.
Does anybody know why Unity won’t give me the same value twice?