I am trying to create a script that will spawn objects at random times, and unfortunately mine isn't working very well. Can you please help me in randomizing the time between the spawns of the Game Objects? Thanks!
#pragma strict
var SpawnObject : GameObject;
var SpawnPoint : GameObject;
var SpawnCounter : int = 0;
var SpawnCounterMinMax : int =0;
var SpawnCounterMaxMax : int =0;
function Update ()
{
var float_min_bother_I_hate_you_js : float = this.SpawnCounterMinMax;
var float_max_bother_I_hate_you_js : float = this.SpawnCounterMaxMax;
var SpawnCounterMax = Random.Range(float_min_bother_I_hate_you_js, float_max_bother_I_hate_you_js);
this.SpawnCounter++;
if (this.SpawnCounter >= SpawnCounterMax )
{
Instantiate(this.SpawnObject, this.SpawnPoint.transform.position, this.SpawnPoint.transform.rotation );
this.SpawnCounter = 0;
SpawnCounterMax = Random.Range(float_min_bother_I_hate_you_js, float_max_bother_I_hate_you_js);
}
}
Aucun commentaire:
Enregistrer un commentaire