Hello,
Right now my random generation does this :
The script is :
#pragma strict
var spawnPositionX : float;
var spawnPositionY : float;
var cloud : GameObject;
var blackcloud : GameObject;
var graycloud : GameObject;
var greencloud : GameObject;
var yellowcloud : GameObject;
var orangecloud : GameObject;
var purplecloud : GameObject;
var bluecloud : GameObject;
var redcloud : GameObject;
var rainbowcloud : GameObject;
var pinkcloud : GameObject;
var go = new GameObject[38];
var rainbowrandom = new GameObject[66];
function Start(){
spawnPositionX = Mathf.RoundToInt (transform.position.x + 4);
go[1] = graycloud;
go[2] = greencloud;
go[3] = yellowcloud;
go[4] = orangecloud;
go[5] = purplecloud;
go[6] = bluecloud;
go[7] = redcloud;
go[8] = rainbowcloud;
go[9] = blackcloud;
go[10] = pinkcloud;
go[11] = pinkcloud;
go[12] = yellowcloud;
go[13] = graycloud;
go[14] = redcloud;
go[15] = redcloud;
go[16] = purplecloud;
go[17] = purplecloud;
go[18] = purplecloud;
go[19] = orangecloud;
go[20] = orangecloud;
go[21] = orangecloud;
go[22] = orangecloud;
go[23] = cloud;
go[24] = cloud;
go[25] = cloud;
go[26] = cloud;
go[27] = cloud;
go[28] = cloud;
go[29] = cloud;
go[30] = cloud;
go[31] = cloud;
go[32] = cloud;
go[33] = cloud;
go[34] = cloud;
go[35] = cloud;
go[36] = cloud;
go[37] = cloud;
go[38] = cloud;
rainbowrandom[1] = blackcloud;
rainbowrandom[2] = blackcloud;
rainbowrandom[3] = graycloud;
rainbowrandom[4] = graycloud;
rainbowrandom[5] = graycloud;
rainbowrandom[6] = rainbowcloud;
rainbowrandom[7] = greencloud;
rainbowrandom[8] = greencloud;
rainbowrandom[9] = greencloud;
rainbowrandom[10] = greencloud;
rainbowrandom[11] = bluecloud;
rainbowrandom[12] = bluecloud;
rainbowrandom[13] = bluecloud;
rainbowrandom[14] = bluecloud;
rainbowrandom[15] = pinkcloud;
rainbowrandom[16] = pinkcloud;
rainbowrandom[17] = pinkcloud;
rainbowrandom[18] = pinkcloud;
rainbowrandom[19] = pinkcloud;
rainbowrandom[20] = yellowcloud;
rainbowrandom[21] = yellowcloud;
rainbowrandom[22] = yellowcloud;
rainbowrandom[23] = yellowcloud;
rainbowrandom[24] = yellowcloud;
rainbowrandom[25] = yellowcloud;
rainbowrandom[26] = redcloud;
rainbowrandom[27] = redcloud;
rainbowrandom[28] = redcloud;
rainbowrandom[29] = redcloud;
rainbowrandom[30] = redcloud;
rainbowrandom[31] = redcloud;
rainbowrandom[32] = redcloud;
rainbowrandom[33] = redcloud;
rainbowrandom[34] = blackcloud;
rainbowrandom[35] = graycloud;
rainbowrandom[36] = purplecloud;
rainbowrandom[37] = purplecloud;
rainbowrandom[38] = purplecloud;
rainbowrandom[39] = purplecloud;
rainbowrandom[40] = purplecloud;
rainbowrandom[41] = purplecloud;
rainbowrandom[42] = purplecloud;
rainbowrandom[43] = purplecloud;
rainbowrandom[44] = orangecloud;
rainbowrandom[45] = orangecloud;
rainbowrandom[46] = orangecloud;
rainbowrandom[47] = orangecloud;
rainbowrandom[48] = orangecloud;
rainbowrandom[49] = orangecloud;
rainbowrandom[50] = orangecloud;
rainbowrandom[51] = orangecloud;
rainbowrandom[52] = orangecloud;
rainbowrandom[53] = cloud;
rainbowrandom[54] = cloud;
rainbowrandom[55] = cloud;
rainbowrandom[56] = cloud;
rainbowrandom[57] = cloud;
rainbowrandom[58] = cloud;
rainbowrandom[59] = cloud;
rainbowrandom[60] = cloud;
rainbowrandom[61] = cloud;
rainbowrandom[62] = cloud;
rainbowrandom[63] = cloud;
rainbowrandom[64] = cloud;
rainbowrandom[65] = cloud;
rainbowrandom[66] = cloud;
}
function Update(){
CreateCloud();
}
function OnCollisionEnter(myCol : Collision){
if(myCol.gameObject.tag == "fallout"){
spawnPositionX = 0;
spawnPositionY = 0;
}
}
function OnTriggerEnter(myCol : Collider){
if(myCol.gameObject.tag == "rainbowcloud"){
var rainbowjackpot = Random.Range(0,66);
Instantiate(rainbowrandom[rainbowjackpot], myCol.transform.parent.gameObject.transform.position,Quaternion.Euler(0,0,180));
Destroy(myCol.transform.parent.gameObject);
if(rainbowjackpot == 5){
Counter.score += 1500;
}
}
}
function CreateCloud(){
if (spawnPositionX < transform.position.x + 15)
{
spawnPositionX += Random.Range(0.5102,4.0142);
spawnPositionY = Random.Range(-1,5);
Instantiate(go[Random.Range(0,39)],new Vector3(spawnPositionX,spawnPositionY,0),Quaternion.Euler(0,0,180));
}
}
I know there are probably easier way to do the arrays but it suits my needs and it is something I understand so please just focus on fixing my random generation problem. Thank you in advance.
I would like to have the clouds spawn like this (separate from eachother just enough to jump to but I dont want them so they are so compact that the game is very easy to play) :
I have already tried to make the minimum x value much higher but then it becomes a cloud to be spawned every few meters. Instead I want it so 2 clouds can spawn with a very close x value but the y value can be different. I was thinking of implementing a distance between the 2 clouds and if it is less than it then it doesn’t get spawned. I just don’t know how to make that happen since I am not the best coder out there.

