How do i use lerp, to make an ai enemy face a target object smoothly? - Thanks.
Something like this:
t += Time.deltaTime; // t is a float (starts at 0.0f)
if (t > 1.0f) t = 1.0f; // when t reaches 1.0f your gameObject will be at the dest rotation
Quaternion start = transform.rotation; // ai start rotation
Quaternion dest; // some other rotation
transform.rotation = Quaternion.Lerp(start, dest, t);
First get the vector from yourself to enemy by doing something like this
Vector3 dirVector = enemy.transform.position - transform.position;
Then get the quaternion which looks towar this by Quaternion.LookRotation or similar stuff. then just use Quaternion.Lerp or Slerp to rotate from your first direction to the target one.