Godot Version
4.3
Question
I’m a beginner!
I have two angles that I want to rotate my Node3D around. One for the X axis and the other for the Y axis. Both work correctly if applied independently, without the other. However, when applying both of them, the result is wrong. Pseudo code:
# Works
my_node.rotation.x = angle_x
#my_node.rotation.y = angle_y
# Works too
#my_node.rotation.x = angle_x
my_node.rotation.y = angle_y
# Does not work: the final rotation is wrong
my_node.rotation.x = angle_x
my_node.rotation.y = angle_y
I thought maybe I need to multiply two quats to have one single rotation, so I’ve tried this:
var x = Quaternion(Vector3(1, 0, 0), angle_x)
var y = Quaternion(Vector3(0, 1, 0), angle_y)
my_node.quaternion = y * x
…but it leads to the exact same result.
It looks like the two rotations influence each other in a way that the second rotation rotates the node with the first rotation already applied. But I think I need the opposite: I want to apply the rotation from some kind of global or world perspective where it does not matter if and how much the node is already rotated.
But being a beginner I lack the correct terms to express what I want in order to find the correct functionality. Therefore I’ll ask in the simplest way possible for me:
How can I apply those two angles in a way that they don’t influence each other?
Thanks a lot!