- Home /
Stop an object from following my coordinates after it did once
var player : Transform;
var distance = 5;
private var playerCloseEnough = false;
private var me : Transform;
function Update(){
var me = GameObject.FindWithTag("Alma").transform;
if(Vector3.Distance(transform.position, player.position) < distance){
me.position = new Vector3(player.position.x + 4 , player.position.y -3 , player.position.z +2 );
playerCloseEnough = true;
}
else{
playerCloseEnough = false;
renderer.enabled = false;
}
}
Comment
Answer by zeest · Jul 25, 2012 at 09:08 PM
If I understand correctly, you want the object to follow your coordinates until playerCloseEnough = true; To do this, enclose the code to make the object follow in a if statement.
if (!playerCloseEnough) {
/*code to follow*/
}
Thank you for helping me out! although this is not exactly what i was looking for but i figured out how to make the script do what i want. but you probaly didnt know what i wanted to occur from poor explaining on my part.