ROTATION BUG ERROR?

The enemy is rotating when I come close to target object. Relevant snippets and screenshots:
Apparently it happens here, whenever I try to chase object:

private void Chase()
    {
            transform.LookAt(enemyOfenemy);
            animator.SetBool("isRunning", true);
            animator.SetBool("isWalking", false);
            animator.SetBool("Idle", false);
            nav.speed = runningSpeed;
            nav.isStopped = false;
            nav.SetDestination(enemyOfenemy.position);
            nav.destination = enemyOfenemy.position;
        
    }

Or Attack it:

void StopOnAttack()
    {
        if (isOnSelectedDistanceToPlayer(attackDistance) && playerInSight)
        {
            animator.SetBool("isRunning", false);
            nav.isStopped = true;
            StartCoroutine("AttackAnim");
        }
        if (!isOnSelectedDistanceToPlayer(attackDistance) && playerInSight)
        {
            Chase();
        }

    }
    IEnumerator AttackAnim()
    {
        animator.SetTrigger("Attack");

        yield return new WaitForSeconds(timeBetweenAttacks);
        animator.ResetTrigger("Attack");

    }

Relevant screenshots:
158068-capture.png

158069-attack-bug.png

Assets that I used:

Like @Masterio identified, your character is trying to face the center of the position of the rectangular object, so as it gets closer it’s going to point up towards that center point. You need it to continue pointing in the correct x-z direction, but not rotate around the Y axis. So you have to zero out the Y axis. Try:

transform.LookAt(Vector3.Scale(enemyOfenemy, new Vector3(1, 0, 1));

Vector3.Scale will multiply the two Vector3’s element by element, so the resulting Vector3 that would be passed to transform.LookAt will be (enemyOfenemy.x, 0, enemyOfenemy.z).