+1 vote

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:
https://www.youtube.com/watch?v=8cdBSxcmiWE&feature=youtu.be

Note that I tried all these and had same results:

# Using Euler
rotation.x += pitch

# Using Euler II
rotate_x(pitch)

# 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)
qRot.set_euler(new_rot)
var new_basis = Basis(qRot)
var new_transform = Transform(new_basis.x.normalized(), new_basis.y.normalized(), new_basis.z.normalized(), transform.origin)
set_transform(new_transform)

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

asked Nov 3, 2019 in Engine by rico345100 (131 points)

1 Answer

+1 vote

Rotating by local axis by rotateobjectlocal, now it works.

answered Nov 4, 2019 by rico345100 (131 points)

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.