Hello Community!
I am giving procedural generation a crack. the goal is to instantiate planes (clouds) in a random area on screen.
In my case 0 - 480 on the x - axis, and 0 - 360 on the y - axis.
The script i’m using is this.
Script.js:
#pragma strict
var blueCloud : GameObject;
var orangeCloud : GameObject;
var cloudChance : int;
var cloudPosition : Vector3;
var cloudX : float;
var cloudY : float;
function Start () {
cloudChance = Random.Range (1, 3);
if (cloudChance == 1) {
cloudX = Random.Range(0, 4.8);
cloudY = Random.Range(0, 3.2);
cloudPosition = Vector3(cloudX, cloudY, - 0.2);
Instantiate (redCloud, cloudPosition, transform.rotation);
}
if (cloudChance == 2) {
cloudX = Random.Range(0, 4.8);
cloudY = Random.Range(0, 3.2);
cloudPosition = Vector3(cloudX, cloudY, - 0.2);
Instantiate (orangeCloud, cloudPosition, transform.rotation);
}
if (cloudChance == 3) {
cloudX = Random.Range(0, 4.8);
cloudY = Random.Range(0, 3.2);
cloudPosition = Vector3(cloudX, cloudY, - 0.2);
Instantiate (blueCloud, cloudPosition, transform.rotation);
}
}
But it only Instantiates the plane (cloud) randomly in the top right part of the screen (never behind or underneath the player).
Thanks for the interest so far!