matching rotation of one object to another on 1 axis only

hi all,
ive got a camera gimbal - one object moving on the y axis, and another object with camera (attached by hinge) moving in the x axis, creating a camera ‘gimbal’, which i move with add torque to their respective rigid bodies for a realistic movement, which works perfectly. i also have a mini map, with a top and a side view (this is a space game in a galaxy so top and side view provide 3d context of location and rotation in space). each of the top and side views in the mini map have a pointer that reflects the location and rotation of the camera location:


here is a code snippet i use to get the top view pointer to match the rotation of the camera gimbal on the cameras y axis, which translates to the pointers (UI) z axis, which works perfectly:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class getlocation : MonoBehaviour
{
	RectTransform topmap;
	galaxy2 galaxy2;
	GameObject camerasphere;
	RectTransform rt;
	float scale;


    void Start()
    {
		rt = GetComponent<RectTransform>();
		topmap = GameObject.Find("blank for galaxytop").GetComponent<RectTransform>();
		galaxy2 = transform.root.GetComponentInChildren<galaxy2>();
		camerasphere = GameObject.Find("camerasphere");
		scale = topmap.rect.width /  (galaxy2.maxx+galaxy2.maxz);
    }

   
    void Update()
    {
		
		Vector3 currentpos = new Vector3(camerasphere.transform.localPosition.x*scale, camerasphere.transform.localPosition.z*scale,0);
		rt.localPosition = currentpos;
		Vector3 temprotation = new Vector3(rt.eulerAngles.x,rt.eulerAngles.y,-camerasphere.transform. eulerAngles.y);

		rt.localRotation = Quaternion.Euler( temprotation);
	
    }
}

the problem arises, however, when i use a similar (near identical) code to get the camera gimbals x axis to translate into the side map views pointers z axis. the pointer doesnt follow the cameras x axis all the way round but only bouces between 180 degrees = 90 + and 90 -. it wont go 360 degrees round, which doesnt make any sense because the same basic code works perfectly from the camera y axis to the pointers z axis. here is the code to get the rotation (and location) of the camera x axis:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class setlocation2 : MonoBehaviour
{
	galaxy2 galaxy2;
	GameObject camerasphere;
	GameObject csg;
	RectTransform rt;
	RectTransform  sidemap;
	float scale;

    void Start()
    {
	galaxy2 = 	transform.root.GetComponentInChildren<galaxy2>();
	camerasphere = GameObject.Find("camerasphere");
	csg = GameObject.Find("cameraspheregalaxy");
	rt = GetComponent<RectTransform>();
	sidemap = GameObject.Find("blank for galaxyside").GetComponent<RectTransform>();
	scale = sidemap.rect.width /  (galaxy2.maxx+galaxy2.maxz);
	
	
	

	
    }

    // Update is called once per frame
    void Update()
    {
		Vector3 currentpos = new Vector3(camerasphere.transform.localPosition.z*scale,camerasphere.transform.localPosition.y*scale,0);
		rt.localPosition = currentpos;

		Vector3 temprotation = new Vector3(0,0,csg.transform. eulerAngles.x);
		rt.localRotation = Quaternion.Euler( temprotation);
    }
}

can anyone help please!?!! I am missing something or could this be a bug?

any help appreciated

many thanks

paul.

in answer to my own question, if anyone else has this problem this might help. i actuall ythink this is a bug and will be reporting it.

i created a ui to diaply the x,y and z euler angles of an object being rotated. when the object is rotated all the way round, as expected the y and z axis display values from 0-360 degrees and then back to zero. the x axis however does not do this. as the object is rotated on its x axis all the way round, it goes from 0-90, then back down from 90-0 again, and then it goes 270-360, and then from 360 -270. it completely misses 90-270 degrees. there is no way to get the object to register x axis degrees 90-270. obviously a bug. read this post: click here for a post that has the same problem and scroll right down to the end for a solution where someone has written their own method for converting quaternions to euler angles, which actually works as expected.