Character moves towards enemy and while attacking it tilts

Hey everyone, i am working on a 3rd person point and click game like diablo. I am stuck in a problem where my character moves towards the enemy and when attacking animation occurs, it tilts. On commenting the line of code where my character faces in the direction of enemy[transform.LookAt(targetedEnemy)], the animation works without any tilting.But then my character does not face the enemy . Here’s the code -

void MoveAndAttack()
    {
        if(targetedEnemy== null)
        {
            return;
        }
        navMeshAgent.destination = targetedEnemy.position;

        if(!navMeshAgent.pathPending && navMeshAgent.remainingDistance > attackDistance)
        {
            navMeshAgent.Resume();
            walking = true;
        }
        else if(!navMeshAgent.pathPending && navMeshAgent.remainingDistance <= attackDistance)
        {
            anim.SetBool("isAttacking", false);
            transform.LookAt(targetedEnemy);
            Vector3 dirToAttack = targetedEnemy.transform.position - transform.position;
           


            if (Time.time> nextAttack)
            {
                nextAttack = Time.time + attackRate;
                anim.SetBool("isAttacking", true);
            }
            navMeshAgent.Stop();
            walking = false;
        }
    }

when this happened to me it was because my guy was looking at the enemy position ( where if you move the enemy in Unity, the transform arrows appear at his feet) so my character would tilt forward aiming at the enemies feet. Is that how yours is tilting? I fixed mine by placing a cube within the enemy about chest high and had that the lookAt target.