[Solved] NPC kinda sorta slides under player

Ok, I’m realizing that my issue might actually encompass many things here. Have been working all night to try and figure it out without having to ask the community, and have made good progress, but seem to be stuck, and am humbly requesting help. Am working with a gravity script. (below, along with the AI script, which for cleanliness of this post will be in the comments) My first problem was the NPC was falling through the terrain. (hold on, put down the angry fingers that want to type “Google it!” I did, that issue is mostly solved.) I’ve come to an interesting issue now that that’s fixed(ish.) Whenever the npc (which is an attacking enemy, btw) gets close to the player, it stops standing upright. It almost appears to go into a slow “baseball slide”, getting a leg stuck partially in the terrain. If the player walks away, the NPC rights itself, and begins pursuing the player again. Any help is genuinely appreciated. Thanks, and God bless.

alt textalt textalt text

  var gravity = 1.0;
    var verticalSpeed= 1.0;
    private var collisionFlags : CollisionFlags;  // The last collision flags returned from controller.Move
     
     
    function Update() {
       
        ApplyGravity ();
     
        // Calculate actual motion
        var movement = Vector3 (0, verticalSpeed, 0) + Vector3.zero;
        movement *= Time.deltaTime;
       
        // Move the controller
        var controller : CharacterController = GetComponent(CharacterController);
        collisionFlags = controller.Move(movement);
    }
     
     
    function ApplyGravity ()
    {
            if (IsGrounded ())
                verticalSpeed = -0.1;
            else
                verticalSpeed -= gravity * Time.deltaTime;
    }
     
     
    function IsGrounded () {
        return (collisionFlags & CollisionFlags.CollidedBelow) != 1;
    }

Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime

Ok so that makes the enemy look at the player. Problem is, when the enemy if far away from the player, it is looking at the center point of the player (it is still doing the problem, but at a much lesser scale), But when the enemy is close if the players center point is higher then the enemy, it will have to change its rotation to look up at the center point. It is easier to show you the problem through an image.

17861-example.png

How you can fix this is either make the center point of the enemy the same height as the player, or make it so the enemy rotates, when looking at the player, only in the desired rotation. Hope this helped!