set rotation Of An object same to the Another except in one axis

Hi All, im trying to write a code for camera that follows the player, i set the rotation and position Of the camera same as the player by this code:

transform.position = shazde.transform.position;
	transform.rotation = shazde.transform.rotation;

but there Is one problem, when I flip the player to walk backward, my camera flips too, the question Is this, How can i make the rotation Of An object same Az another one, just in some axis that i want not in all axis. or at least how can i freeze the camera rotation in one axis?

transform.eulerAngles = new Vector3(transform.eulerAngles.x, shazde.eulerAngles.y, transform.eulerAngles.z);

This will update the camera’s y rotation to be the same as the player’s y rotation.

I found a solution for myself from checking all around google, this is what worked for me in CSHARP:

EmptyObject.transform.localEulerAngles = new Vector3(0.0f,transform.localEulerAngles.y, 0.0f);

The script is attached to the camera, my empty object emulates 1:1 the Y rotation from the camera, all other combinations that I have seen from the internet copy it in the ratio of 1:100 or other gibberish.

use Quaternion.Euler…

transform.rotation = Quaternion.Euler(shazde.transform.rotation.x,transform.rotation.y,shazde.transform.rotation.z,);