In the flying template, when flying towards upwards or downwards 90 and -90 yaw, gimbal lock occurs. To experience this, first, you want to unpin "Set Current Roll Speed." Next fly upwards (continually hold the 'D' key or the up arrow). You will notice a jarring flip happen while loopdy looping in the air, rather than a smooth ride. This is the gimbal lock. This occurs when two axis are rotated the same direction on the gimbal. To fix this we can use Quaternions instead of rotators, which have a fourth axis parented to the middle axis that can be used if the middle axis gets locked with the outer axis.
I have been researching how to fix this phenomenon. However, I have no idea how to correctly use Quaternions in UE4 blueprints. Here are my blueprints for setting up the rotation of my ship pawn (my ship pawn is a separate blueprint from my camera so that it can lag behind the camera). How can I incorporate Quaternions to eliminate the gimbal lock?


Heres a gif of the Gimbal Lock while Looping.
UPDATE:
So it turns out Quaternions are not super exposed to blueprints. However I found a Rotator to Quat Macro made by one of the wonderful staff at Epic Games. Thanks, ZoltanE!
http://zspline.net/files/RotatorToQuat.uasset
I found an equation online for making a Quad to Rotator Macro.
I hope it is correct.
I have been researching how to fix this phenomenon. However, I have no idea how to correctly use Quaternions in UE4 blueprints. Here are my blueprints for setting up the rotation of my ship pawn (my ship pawn is a separate blueprint from my camera so that it can lag behind the camera). How can I incorporate Quaternions to eliminate the gimbal lock?
Heres a gif of the Gimbal Lock while Looping.
UPDATE:
So it turns out Quaternions are not super exposed to blueprints. However I found a Rotator to Quat Macro made by one of the wonderful staff at Epic Games. Thanks, ZoltanE!
http://zspline.net/files/RotatorToQuat.uasset
I found an equation online for making a Quad to Rotator Macro.
roll = Mathf.Atan2(2*y*w + 2*x*z, 1 - 2*y*y - 2*z*z);
pitch = Mathf.Atan2(2*x*w + 2*y*z, 1 - 2*x*x - 2*z*z);
yaw = Mathf.Asin(2*x*y + 2*z*w);
pitch = Mathf.Atan2(2*x*w + 2*y*z, 1 - 2*x*x - 2*z*z);
yaw = Mathf.Asin(2*x*y + 2*z*w);
Comment