Can someone provide me with a script that every three minutes a meteor falls on my land, the meteor would be a ball, if you get close you can win stuff would be a stardust
This is just one way of doing it, don’t really need to instantiate clones if you don’t want too.
var ballGameObject : GameObject; //drag ball object from editor here
var ballGameObjectClone : GameObject;
var craterObject : GameObject; //drag crater object from editor here
var craterObjectClone : GameObject;
Start () {
StartCoroutine(“TimedMeteorFall”);
}
function TimedMeteorFall () {
while(true) {
ExecuteMeteorFall();
yield WaitForSeconds(180);
}
}
function ExecuteMeteorFall() {
// execute the ball falling on your land code here
ballGameObjectClone = Instantiate (ballGameObject);
ballGameObject.transform.position = Vector3(0,500,0);
}
function Update () {
if(ballGameObjectClone != null) {
ballGameObjectClone.transform.position.y -=5;
if(ballGameObjectClone.transform.position.y <0) {
craterObjectClone = Instantiate (craterObject);
craterObjectClone.transform.position = ballGameObjectClone.transform.position;
Destroy(ballGameObjectClone);
ExecutePrizeWinnings();
}
}
}
function ExecutePrizeWinnings() {
//put all the prize winning stuff that you want to do here
}