Enemy Nudging Towards Player

I’ve got my enemy to look at and chase the Player, but once he gets to the distance where he should stop chasing the Player, he’ll do tiny nudges towards the Player, getting closer to him. Anyone have a clue why this is happening?

if(targeted){ 
    		var rotation = Quaternion.LookRotation(Player.transform.position - transform.position);
    		transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
    		transform.eulerAngles = new Vector3(0,transform.eulerAngles.y,0);
    		ChasePlayer = gameObject.GetComponent("EnemyControl");
    		if(distanceToTarget >= 3){
    			isMoving = true;
    		}else{
    			isMoving = false;
    		}
    	}else{
    		isMoving = false;
    	}
    //CHASE THE PLAYER//
    	if(isMoving && distanceToTarget >= 3){
    		animation.CrossFade("run",0.2);
    	    var controller2 : CharacterController = GetComponent(CharacterController);    
    		var forward : Vector3 = transform.TransformDirection(Vector3.forward);
    		controller2.SimpleMove(forward * 3);
    	}

because once he reaches the player he stops moving (or moves backwards a little to get to the limit radius/range), then next frame, he is out of range again, so he moves in range again, and this repeats… hence the jittery movement.

You can fix it in several ways…

  1. make it so the enemy cant move faster than the player.
  2. make it so the speed he chases the player is variable speed, not just true or false for chasing the player (more speed when further) less speed when very close (match player’s speed)