Quaternion, Eulers and Problems

Good afternoon. I have the following problem with conversion of quaternions. For the explanation I will write the direct code:

float zAn = 40;
float yAn = -56;
Quaternion myq = Quaternion.Euler(0, 0, zAn);
Cube.rotation = myq;
Cube.Rotate(Vector3.right, yAn, Space.self);
Quaternion myqD = Cube.rotation;
Cube.Rotate(Vector3.forward, -zAn, Space.world);
Debug.Log("MyAng " + Cube.eulerAngles.x + "  " + Cube.eulerAngles.y + "  " + Cube.eulerAngles.z);

From debug I see (-56, 0, 0). That that also is necessary to me. But a problem that at me myqD is known only. How to calculate zAn if myqD is known only? Thanks in advance for the help.

when you call a variable like Quaternion or Vector3, they wont be update from Cube by itself. It just hang on that value you set in the line so if you want to make it realtime you should set the value of myqD again after you Rotate the Cube.

Just move the this line down to the bottom before the Debugging.

Quaternion myqD = Cube.rotation;

I’m not sure if my answer is what you want to know
so please comment after you read this, I hope it works :slight_smile: