When the AI for my game moves towards the player, they will have a extreme rotation and jitter to their movement. Here is the code that I am working with.
function Mover(target : Vector3)
{
// While moving we want to also Rotate
var diffVector: Vector3 = target - transform.position;
var movement : Vector3;
if(diffVector.magnitude > 1)
{
movement = (diffVector.normalized * speed);//without this it will run toward something and slow down when it gets close.
}
else
{
currentPoint = (currentPoint + 1) % waypoints.length;
}
movement.y -= gravity * Time.deltaTime;
controller.Move(movement * Time.deltaTime);
transform.LookAt(target);
}
I am pretty sure that this is where my issue is but I am just not seeing it. Any help would be greatly appreciated.