Tank Turret isn't in a right rotation

Hi this is Fender and I’ve been experimenting with tank movement but when it comes to the movement of the turret in a slope, it’s x and z rotation is wrong.

also if I switched to local Rotation, its all different and not what I want.
so here is the main code:

public class TurretRotation : MonoBehaviour
{

    public Transform turret;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        turret.rotation = Quaternion.Euler(0, Camera.main.transform.eulerAngles.y,0).normalized;
    }
}

also I’m using "“Cinemachine” and my age is 12 so if you can help me that would be greatly appreciated.

What you are using are the global rotation variable. I think it should work if you used the local variable ( transform.rotation => transform.localRotation). This would mean that your tanks turret rotates around it’s local Y axis rather than the worlds Y axis. There is also localEulerAngles which might be easier than using Quaternion.Euler() to convert it first. Hope it helps! :smiley:

can you give me an example cause Im not good at those math.
also when I use this code:

 turret.localRotation = Quaternion.Euler(0, Camera.main.transform.eulerAngles.y,0).normalized;

and it also works but if I rotate my tank, it will not follow the camera’s y angle