Quaternion.LookRotation() regarding parent

My 3D object consists of 2 parts:
base
turret
when I find enemy and try to rotate my turret to it - work nice!

turretlookAtTarget = target.transform.position - transform.position;

turretRot = Quaternion.LookRotation(turretlookAtTarget);
transform.rotation = Quaternion.Slerp(transform.rotation, turretRot, RotateSpeed * Time.deltaTime);

But when my 3d object move up or down on hill turret look at target in global axis (or I don’t know), not as a part of base and it looks like not in real life(( How create lookAtRotation regarding my base? Please Help!

You can either set the y value of both the vectors to 0 or the same value before calculating the rotation so it doesn’t rotate on the y-axis or you can restrict the rotation on the y-axis. It depends on what you are trying to achieve.

This works , thanks!

transform.localEulerAngles = new Vector3 (0, transform.localEulerAngles,0);