I’m making a building thing that makes stuff and I need it to know when a object gets to a certain spot.
var waitTime = 5;
var Builders : GameObject[];
var col : boolean = false;
var start : boolean = true;
var prefab : Transform;
var called : boolean = false;
function Update ()
{
//trying to tell when it is there then stop it and spawn a object
if(Builders[0].transform.position == Vector3(-2, 0, 0))
{
col = true;
}
if(col == false && start == true)
{
Builders[0].transform.Translate(Vector3.forward * Time.deltaTime / waitTime);
if(called == false)
{
Build();
called = true;
}
}
if(col == true)
{
Instantiate (prefab, Vector3(8, 0, 0), Quaternion.identity);
}
}
function Build()
{
//trying to make it wait until it gets there
while(col == false){
yield;
}
col = true;
called = false;
}
thanks in advance