Basic toggle timer Help!

Ok…
So i want the variable “myVariable” to randomize a number from 1, through 3 so that the possible numbers are 1, 2, and 3.
BUT i wanna to generate a random number EVERY SECOND…
so whats the SIMPLEST way to do this???

   thanks, Gabriel

The simplest way to do this is with InvokeRepeating and a memeber variable integer ‘number’. In JS it goes like this-

var currentValue : int = -1;
var minValue : int = 1;
var maxValue : int = 3;
var randomisationInterval : float = 1;

function Start()
{
    InvokeRepeating("Randomise", 0, randomisationInterval);
}

function Randomise()
{
    currentValue = Random.Range(minValue, maxValue + 1);
}

Then, you just access ‘currentValue’.

var lock = false;
var myVariable = 1;

function Update(){
   if !(lock)
      RandomizeIt();
}
    
function RandomizeIt(){
   lock = true;
   yield WaitForSeconds(1);
   myVariable = Random.Range(1,4);
   lock = false;
}