bool RotateTowards (Vector3 trotdir) {
Quaternion rot = tr.rotation;
trotdir.y = 0;
if (trotdir != Vector3.zero) {
Vector3 trot = Quaternion.LookRotation (trotdir).eulerAngles;
Vector3 eul = rot.eulerAngles;
eul.y = Mathf.MoveTowardsAngle(eul.y,trot.y,rotationSpeed*deltaTime);
tr.rotation = Quaternion.Euler(eul);
//Magic number, should expose as variable
return Mathf.Abs(eul.y-trot.y) < 5f;
}
return false;
}