I'm trying to create a script, so that when the object 'runner' is 500m away, a rigidbody will be added. I've looked through the scipting manual, yet that produces an error, which I cannot solve. Where am I going wrong?
var runner : transform;
var closeDistance : float = 500;
function Update (){
if (runner) {
var dist = Vector3.Distance(runner.position, transform.position);
if (dist < closeDistance);
if(!dist.gameObject.rigidbody){
dist.gameObject.AddComponent(Rigidbody);
}
}
}
Thanks.