Rotation of child object on X axis breaks rotation of parent object on Z axis

As shown below, rotation on Z (by 55) axis for “Camera Flat Rotation” propagates into “Main Camera” and perfectly counteracts applied rotation (by -55).
(“cameraFlatRotationBody” is an empty game object and a parent of main camera)




Disabling child rotation fixes the issue:


The goal is to implement standard camera movements for a strategy game:

  • “left-right” rotations are global and always in parallel to terrain plain
  • “up-down” are local and result to over the head rotations.

I’ll probably have to implement this via transform.Rotate(0, 0, zRotation, Space.World) and transform.Rotate(xRotation, 0, 0, Space.Self)… BUT, why exactly solution above isn’t working. Am I missing something?

Edit: Solved this problem on my own, code above didn’t work because I tried to override rotation twice. Final solution is:

            transform.RotateAround(target, Vector3.up, dx * cameraRotationSpeed * Time.deltaTime);
            transform.RotateAround(target, transform.right, dy * cameraRotationSpeed * Time.deltaTime);