I have a coyote that I am trying to get to chase my character this is the chase code that I have:
var moveDirection : Vector3 = target-transform.position;
var distFromPlayer : Vector3 = player.position-transform.position;
var velocity = rigidbody.velocity;
if(moveDirection.magnitude<1){
currentWaypoint++;
}
else if(distFromPlayer.magnitude<30){
velocity = Vector3.zero;
target=player.position;
velocity = (player.position - transform.position).normalized*speed;
if((player.position-waypoint[currentWaypoint].position).magnitude>50){
target = waypoint[currentWaypoint].position;
velocity= moveDirection.normalized*speed;
}
}
else{
velocity= moveDirection.normalized*speed;
}
}
else{
if(loop){
currentWaypoint=0;