After rotated by Z-axis, X/Y axis still rotating just like z is 0

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By rico345100

I’m making aerial vehicle controller, which can rotate 3 axis: X(Pitch), Y(Yaw), Z(Roll).

Rotating x(pitch) and y(yaw) axis works fine, however after I rotated z(Roll) axis, x/y rotation gave me weird result, it seems like it still rotating just like z axis didn’t rotated(0).

First I thought that it was some kind of gimbal lock problem, but it wasn’t, it still happens using quaternion.

Here’s the video I demonstrate:

Note that I tried all these and had same results:

# Using Euler
rotation.x += pitch

# Using Euler II

# Using Quaternion
var qRot = Quat(transform.basis)
var r_euler = qRot.get_euler()
var new_rot = Vector3(r_euler.x + pitch, r_euler.y, r_euler.z)
var new_basis = Basis(qRot)
var new_transform = Transform(new_basis.x.normalized(), new_basis.y.normalized(), new_basis.z.normalized(), transform.origin)

Is there a something that I missed? Any advice will very appreciate it.

:bust_in_silhouette: Reply From: rico345100

Rotating by local axis by rotate_object_local, now it works.

Hi, I am stuck there too, can you write what you have changed in the code

Okan Ozdemir | 2020-03-22 05:50