Hello everyone,
I have a small problem when using the rotation of GameObject A and use it for other GO’s. Basically I have this cube and 3 cylinders (fbx model), one cylinder for each axis, in the code I have added the rotation values for each cylinder so they dont get overlaid.
Now when I rotate the cube, the indicators should follow. I tried using the cylinders as childs but thats no option for me as to the scaling issue of child elements which I want to avoid.
When I rotate the object the X and Y-Axis cylinder works fine except the one for the Z-Axis. Once I start rotating the object its all over the place, I also made a short video for demonstration…
public GameObject CylinderXAxis;
public GameObject CylinderYAxis;
public GameObject CylinderZAxis;
void Update()
{
var eulerAngles = this.transform.eulerAngles;
Vector3 newScaleX = new Vector3(eulerAngles.x, eulerAngles.y, eulerAngles.z + 90);
CylinderXAxis.transform.eulerAngles = newScaleX;
Vector3 newScaleY = new Vector3(eulerAngles.x, eulerAngles.y, eulerAngles.z);
CylinderYAxis.transform.eulerAngles = newScaleY;
Vector3 newScaleZ = new Vector3(eulerAngles.z, eulerAngles.y - 90, eulerAngles.z + 90);
CylinderZAxis.transform.eulerAngles = newScaleZ;
}
Any help is apreciated.
best regards,
Alex