I have looked around at least three days now and I can't seem to find anything about incorporating a disable script along side a waypoint script.
Essentially I want the AI to become disabled as soon as it has finished its last waypoint. How would I begin to do this? Below is the script.
SCRIPT
EDIT-> I have changed the original script to support the ones the people who have answered my question. Thanks!
var waypoint : Transform;
var speed : float = 20;
var distanceToTarget : float = Vector3.Distance(transform.position, EvilCube);
function Update() {
var target : Vector3 = waypoint.position;
var moveDirection : Vector3 = target - transform.position;
var velocity = rigidbody.velocity;
if(moveDirection.magnitude < 1){
velocity = Vector3.zero;
if(distanceToTarget == 0)
this.EvilCube.active = false;
}
else{
velocity = moveDirection.normalized * speed;
}
rigidbody.velocity = velocity;
}