I have a script that creates a coin at rate seconds and every rate seconds, rate is decreased by fasterRate. This should create the coins faster and faster, but the InvokeRepeating() called with rate is only called at start so that it doesnt get faster and faster but just stays the same rate. I need a way to call CreateCoin() faster and faster. Thanks!
#pragma strict
var xpos : float;
var spawnpoint : Vector3;
var coin : GameObject;
var rotation : Quaternion;
rotation.eulerAngles = new Vector3(0, 0, 0);
var newCoin :Object;
var rate : float = 3.0;
var fasterRate : float = 0.1;
function Start () {
InvokeRepeating("CreateCoin", 1, rate);
}
function Update () {
Destroy(GameObject.FindWithTag("Coin"),10);
}
function CreateCoin(){
xpos = Random.Range(-50.0,50.0);
spawnpoint = new Vector3(xpos, 80, 0);
var myColor : Color; // This is just working for another part of my script, Please Ignore.
var mode : boolean = Random.value > 0.5f;
var rand : float = Random.value;
var index : int = Random.Range( 0, 3 );
myColor[index] = rand;
myColor[( index + ( mode ? 1 : 2 ) ) % 3] = 1;
myColor[( index + ( mode ? 2 : 1 ) ) % 3] = 0;
newCoin = Instantiate(coin, spawnpoint, Quaternion.identity);
//newCoin = newCoin as GameObject;
//newCoin.renderer.material.color = myColor;
rate = rate - fasterRate;
}