I’m making a game with procedural generation for each level. At the beginning I want to create a random number of game objects(done) at a random distance(sorta done). So right now I have a random number of game objects being formed at a distance (with Random.Range(1000, 6000)). But I don’t want it to be just positive, for example, generate a number between -6000 and 6000 excluding anything smaller than 1000 and greater than -1000. After looking around the only way that came to me was using a random number between 1 and 4 where the number would be the quadrant it’d be in and then use a switch loop for each possible case.
switch (wormhole[curWormholeGen]){
case 1:
switch(genQuadrant){
case 1:
Instantiate (wormholeType1, transform.position + new Vector3(Random.Range(minX, maxX), 0, Random.Range (minZ,maxZ)), transform.rotation);
break;
case 2:
Instantiate (wormholeType1, transform.position + new Vector3(-Random.Range(minX, maxX), 0, Random.Range (minZ,maxZ)), transform.rotation);
break;
case 3:
Instantiate (wormholeType1, transform.position + new Vector3(-Random.Range(minX, maxX), 0, -Random.Range (minZ,maxZ)), transform.rotation);
break;
case 4:
Instantiate (wormholeType1, transform.position + new Vector3(Random.Range(minX, maxX), 0, -Random.Range (minZ,maxZ)), transform.rotation);
break;
}
this is just a snippet from a part of the code. There’s also a random length for the array etc… There must be a more effective way than this right?
Thanks for the help,
Troponeme