Child object rotations are wrong

I have an issue with getting a gun to rotate around the x axis.

I had a player prefab set up before that was working but due to some networking stuff I had to restructure it. After restructuring the prefab, the gun rotation around the x-axis is broken.

Basically the gun prefab is made up of several objects (the model, grenade spawns and bullet raycasting origin) that appear like so in the following hierarchy:
-gun
-grenade spawn
-model
-raycasting origin

Unfortunately when I rotate the gun around the x axis based on the camera rotation, the grenade spawn and raycasting origin objects both rotate correctly (appearing in the correct position on the screen) however the model seems to be rotating too much.

Here is the code in the gun script that governs the rotation…but I don’t think it’s correct because no matter what i change the rotation to, each component is relative, so if i fix the model rotation, the grenade/bullet raycasting objects rotations will be wrong.

NOTE: THE TARGETYROTATION AS ACTUALLY THE ROTATION AROUND THE X AXIS.

targetXRotation = Mathf.SmoothDamp(targetXRotation, playerView.GetComponent<MouseLook>().rotationX, ref targetXRotationV, rotationSpeed);
		targetYRotation = Mathf.SmoothDamp(targetYRotation, -cameraView.GetComponent<MouseLook>().rotationY, ref targetYRotationV, rotationSpeed);

		transform.position = cameraView.transform.position + Quaternion.Euler(targetYRotation, targetXRotation, 0) * new Vector3(0,0,currentRecoilZPos);

		//Debug.Log ("rotating around the x axis by: " + targetYRotation + " degrees");
		Debug.Log ("Cameras rotation around the x axis is: " + cameraView.GetComponent<MouseLook>().rotationY);
		transform.rotation = Quaternion.Euler (targetYRotation, targetXRotation, 0);

The below screenshots illustrate what is happening.

I had a similar problem. Check if you have a parent transform with uneven scaling.

Figured it out. I had a culling mask for all the gun prefabs and it was placed outside of the main camera when I restructured the Player prefab. Once I mad the culling mask a child of the main camera, everything went back to normal because now the culling mask rotates exactly with the main camera.

I guess I didn’t really provide enough information for this one as I was unaware it had anything to do with the culling mask.