Hi!
I’ve written a random number script. It works fine, except for the fact that when it has picked every number within the range, it stops.
I have it print out what it gets in the Debug.Log. Is it because of the Debug.Log that it stops after picking every possible number, or is there a better way to script this?
This occurs only in the int version of the random number when it is getting a new one every frame. I’m sure it would happen with the float version too, but the possibilities for a floating point number are endless.
var everyframe : boolean = false;
var floatnum : boolean = false;
var lowestfloat : float = 0.0;
var highestfloat : float = 0.0;
var lowestint = 0;
var highestint = 0;
function Awake(){
if(everyframe == false){
if(floatnum == true){
var choice = Random.Range(lowestfloat,highestfloat);
}
if(floatnum == false){
choice = Random.Range(lowestint,highestint);
}
Debug.Log(choice);
}
}
function Update () {
if(everyframe == true){
if(floatnum == true){
choice = Random.Range(lowestfloat,highestfloat);
}
[COLOR="#ff0000"]if(floatnum == false){
choice = Random.Range(lowestint,highestint);[/COLOR]
}
Debug.Log(choice);
}
}