This spawn script is suppose to spawn an object every 1-5 seconds, depending on the random number chosen. I debuglogged the number and its being randomized, but only one object spawns, and that’s when the game loads. Is it because the “number” variable is changing so much that its not working? Any help would be appreciated.
var prefab : Rigidbody;
var Stuff : Transform;
var number : int;
InvokeRepeating("Randomize",0,1);
function Randomize() {
number = Random.Range(1,5);
Debug.Log(number);
}
InvokeRepeating("Spawn",0,number);
function Spawn () {
var Spawn : Rigidbody;
Spawn = Instantiate(prefab, Stuff.position, Stuff.rotation);
}