How can I avoid Gimbal Lock with Rotations?
I've unlocked the Character Capsule's Pitch and Roll rotations. I've setup a MakeRotZX from the Characters location in Z, and the characters Forward Vector in X, which produces the characters Up Vector Always pointing towards the Worlds Center (0,0,0), Leaving only the Yaw available for mouse input to rotate the character along it's Yaw. This works up until the character capsule has tilted around 90 degrees, at that point the Rotation starts to Gimbal lock and fall over onto it's side (it's up vector no longer pointer towards the desired coordinate and Yawing the character no longer rotate along it's yaw only).
1) Is there a way I can fix this inside of BluePrint? It was suggested that I try to only rotate the Pitch and Roll first (zeroing out the Yaw) and then Rotate this Rotation Vector by the desired Yaw Input Rotation and then set the character to that result. However I either this doesn't work, or I wasn't correctly setting it up.
2) So, If this is a possibility does anyone know the correct way to do this in BluePrints?
3) If it's not possible to avoid Gimbal Lock in blueprints (without compromising the functionality I'm looking for described above) how can I do this in Code using Quaternions?
Thanks in advance!
asked Jun 27 '14 at 04:30 PM in Blueprint Scripting
Use Combine Rotator node, Combine the rotators of the turning rotation, from the input axis turn float with the MakeRotZX, z = actor location * -1, x = actor forward vector. This stopped the camera from wobbling into Gimbal lock near the poles. It also stopped the control from completely flipping on the opposite hemisphere.
answered Jun 30 '14 at 09:22 PM
I have been using Add Actor Local Rotation and letting the player rotate on all 3 axes like in Descent. It doesnt seem to gimbal lock when i roll, pitch and yaw anywhere i want, but i have only tested it for a few minutes and maybe didnt hit the sweet spot that would lock it. I guess if it happens I'll rewrite that part using combinerotators.
answered Aug 30 '17 at 06:00 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here