I been trying to get this function to stop rotating when the model does not have to rotate anymore. I have tried checking the models current rotation against the look rotation to see if they are the same. I have also tried comparing the y value of the quaternions because thats what I am rotating on. Any help would be greatly appreciated.
function RotateTowards (position : Vector3) : boolean {
var direction = position - transform.position;
direction.y = 0;
if( transform. rotation ==Quaternion.LookRotation(direction))
return true;
// Rotate towards the target
transform.rotation = Quaternion.Slerp (transform.rotation, Quaternion.LookRotation(direction), rotationSpeed * Time.deltaTime);
//transform.eulerAngles = Vector3(0, transform.eulerAngles.y, 0);
return false;
}