to rotate along z axis

i need the camera to rotate along z axis as the player moves left/right,currently the camera rotates along y axis (since i am using lookrotation).How can i modify code to rotate along z axis…m bit weak in maths facepalm;/

public Transform target;
public float tiltAngle;

void Update() 
{
Vector3 relativePos =target.position - transform.position;
transform.rotation=Quaternion.RotateTowards(transform.rotation,Quaternion.LookRotation(relativePos),Mathf.Deg2Rad*tiltAngle);

}

I’m not sure of your Mathf.Deg2Rad*tiltAngl and how that maps to your angle. Here is some code that points in the right direction. You might need to add or subtract from angle (usually 90 degrees) before using it in AngleAxis() to get the rotation you want:

void Update() 
{
    Vector3 relativePos =target.position - transform.position;
    float angle = Mathf.Atan2(relativePos.y, relativePos.x) * Mathf.Rad2Deg;
    transform.rotation=Quaternion.RotateTowards(transform.rotation,Quaternion.AngleAxis(angle,transform.forward),Mathf.Deg2Rad*tiltAngle);
}