Locking an AI enemy's Y rotation and position.

Hi I’ve got this AI enemy tank that rotates and shoots through the floor and sinks into the floor after it kills the player when player respawns lower than it. I’m trying to prevent the AI from being able to go lower or higher on Vector Y and also lock it’s ability to rotate on Vector Y.

I’ve tried using Euler angles to freeze the Y rotation, with really weird unusable results.

These two parts of the code are the parts I believe are making things go badly. I’ve tried looking for documentation and applying other posts.

I also added a rigidbody to the tank and tried to freeze its Y position and rotation that way but it didn’t work.

Any insight would be awesome.

    void lookAtPlayer()
    {
        Quaternion rotation = Quaternion.LookRotation (player.position - transform.position);
        transform.rotation = Quaternion.Slerp (transform.rotation, rotation, Time.deltaTime * rotationDamping);
    }

   
    void chase ()
    {
       
        transform.Translate (Vector3.forward * moveSpeed * Time.deltaTime);
        Vector3 eulerAngles = transform.rotation.eulerAngles;
        eulerAngles = new Vector3(eulerAngles.x, 0, eulerAngles.z);
        transform.rotation = Quaternion. Euler(eulerAngles);

       
    }

You sure you have your axes correct? If the tank is rotating to face something above or below them, you want to freeze the X rotation axis to prevent that. Rotating around the Y is like spinning a top.