Camera rotation independent from parent object

So i have this object that i can move using the mouse. My camera is linked as a child object to my character.
When i move the mouse left, the char goes left and it also rotates 15°.
My camera also rotates 15° but i don’t want that. I want my camera to be stable but still linked to my character because he must follow it everywere.

THis is what i have so far:

changeX = Input.GetAxis("Mouse X");
if(changeX != 0)
	{
		if(changeX > 0) 
		{
			transform.eulerAngles.x = 15;
			mainCamera.transform.eulerAngles.x = 0;
		}
		else
		{
			transform.eulerAngles.x = -15;
			mainCamera.transform.eulerAngles.x = 0;
		}
	}

I tried it with localEulerAngles. Different setting like -15 and +15 when the character rotates +15 and -15 but it seems my camera does not respond to my values.

Instead of making the camera a child of the object and then compensating for inherited rotation, it’s probably easier to make them hierarchically independent, but put a script on the camera that sets its position to that of the object every frame. Or you could have the script that moves the object move the camera directly as well.