In this lecture (Rotate to Face Target), the vector “direction” is normalized.
Then, the LookRotation method is passed new Vector3(direction.x, 0, direction.z).
But, if the player and enemy are at different height levels, this vector passed to LookRotation is not normalized (though that wouldn’t be noticed in the example where they both move on a horizontal plane). If I remember right, LookRotation (in a Debug context, such as playing in editor) throws an exception if it gets a vector of length not equal to 1.
Thus, I used the following code instead:
Vector3 direction = target.position - transform.position;
direction.y = 0;
transform.rotation = Quaternion.LookRotation(direction.normalized);