Object Creation Speed incease

Hey basically i have an object creation script that creates objects at a random x and y position every 10 seconds(changable)

var Occurence = 3;

var Block : GameObject;

var time = 0.0;

function Update() {

if(Time.deltaTime * 1 && Time.time > time){

time = Time.time + Occurence;

var position: Vector3 = Vector3(Random.Range(-53.0, 53.0), 80, Random.Range(-1.5, -1.5));

Instantiate(Block, position, Random.rotation);

}

}

it works perfectly except that i want it to make the objects faster as the level goes on for a harder game. If you have ever played the ds game Meteos, that is kinda what i am looking for.

You could increase the time scale. For example:

Time.timeScale = 2.0f; // default is 1

So to increase it exponentially:

Time.timeScale += Time.deltaTime/10; // double time scale after 10, 5, 2.5, etc. seconds

Or linearly:

Time.timeScale += Time.deltaTime/(10*Time.timeScale);

Of course, you should clamp the value to a reasonable maximum (such as 10).


Another solution would be to keep a velocity factor for all of your object. And increase this factor by a small amount every frame.

Hey thanks for answering but if i did time.timeScale increase, it would speed up everythin else in the game too. I tried this instead, i think it works.

var Occurence = 3;

var Block : GameObject;

var time = 0.0;

var timeIncrease = .1;

function Update() {

// if the time in seconds is faster than the time(always will be) then the time will be the the

//time plus the occurnce time minus the timeIncrease to make a faster rain.

if(Time.deltaTime * 1 && Time.time > time){

time = Time.time + Occurence - timeIncrease;

var position: Vector3 = Vector3(Random.Range(-53.0, 53.0), 80, Random.Range(-1.5, -1.5));

Instantiate(Block, position, Random.rotation);

}

}

Basically i took how fast in seconds they were appearing and subtracted it by how fast i want it to speed up.