is there a more controllable way to load random placed platforms?

in my 2d platform game the user control a ball. this ball have to jump over cubes which are randomly placed on randomly loaded platforms which moving from right to left across the screen.

when the game starts the ball stays on a longer platform than the loaded platforms. so i can control the distance between the first platform and the first loaded platform. currently i control the distance between the following loaded platforms with a random WaitForSeconds before the LoadPlatforms() function is called again. same thing with the cubes. the speed of the platforms and the cubes i control with an other script.

now the problem is i want to increase the speed of the platforms if the score is bigger. but when i increase the speed of the platforms and the cubes the distance of the platforms is uncontrollable.

can someone give me an idea to make the hole thing more controllable?

``````var MyArray = new Array("badcube","badcube2","badcube3");

function Start (){
while(true){
yield WaitForSeconds(Random.Range(2.5, 2.8));
}
}

var instance : GameObject = Instantiate(Resources.Load("platform1"));
instance.transform.position.x=20;
instance.transform.position.y=Random.Range(-0.7, 0.6);
instance.transform.position.z=0;
for (var i = 0; i < Random.Range(1, 3); i++){
var instance2 : GameObject = Instantiate(Resources.Load(MyArray[Random.Range(0, MyArray.length)]));
instance2.transform.position.x=Random.Range(17, 23);
instance2.transform.position.y=2;
instance2.transform.position.z=0;
}
}
``````

and the script i use for the speed of the platforms and the cubes:

``````function FixedUpdate () {

transform.position.x  -= 0.1;

////with tilt control

//transform.Rotate(0, 0, -Input.acceleration.y);
transform.Rotate(0, 0, Input.GetAxis("Horizontal")/10);
}
``````

So, this is a side scrolling puzzle game? I am afraid I dont see where you are controlling a ball but I do see some inherent problems. You are creating all the cubes at Y 2, and creating the platform at Y -0.7 to 0.6. This doesnt allow for any stacking. I could be wrong but it looks like the player controls the rotation of the platform even while the platform is moving. Hence my confusion about what the player is doing.

If there is a ball here someplace, and a moving platform, you may wish to change the random drop to a timed drop. This will give the player some area to jump over balls. So say your standard drop is 0.5 seconds per drop, which gives zero room between the boxes for a ball to jump and 1 second interval would give the player just enough room to squeek a ball through. In this case you simply use timed allotments to handle boxes thus consistently giving the player a method to win. even if the timing is harsh at high levels. You could actually create 10 or so allotments and multiply the timing of those allotments by a level modifier, thus making it tougher to complete the level. Also, as you progress through levels, you could give different types of boxes that do different things.

Just a thought.