x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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!

Product Version: Not Selected
Tags:
more ▼

asked Jun 27 '14 at 04:30 PM in Blueprint Scripting

avatar image

Thumper
956 137 147 385

avatar image Default816 Jan 28 '19 at 08:09 PM

So, does anybody know the answer to this in blueprints? i am at wits end, cause nothing seems to work... I have tried what is marked as Answers, and it doesn't work. I specify that my camera is fixed and that i am using the mouse to rotate the character ( top-down mouse oriented ) . Issue happens during the turn in place, if i move the cursor behind the character ie. opposed to the vector's forward direction.

avatar image Nebula Games Inc Jan 28 '19 at 08:19 PM

I fixed it with quaternions and posted a link to the tutorial. It involves adding C++ to your project but I literally walk you through it and all you do is copy/paste code. Not sure if you checked it out and it doesn't work for your set up or not but figured I would at least let you know about it since it is not marked as an "accepted answer" on this question.

avatar image Darkentik Jan 28 '19 at 08:21 PM

It can´t be fixed in BPs right now because the only way to fix this 3D problem is to use the mathematically operation with so called quaternions. So, i decided to buy this one form the marketplace for little money and use it. It costs only 20€ and it uses the mentioned quaternions like i said in C++ code.

avatar image Thumper Jan 28 '19 at 08:40 PM

You can make a solution in BP, anyone suggesting otherwise is wrong. Here's a solution I've made to add rotations into a rotation. I suggest making this into a BP function that you can you in your project.

Get current forward vector (the vector the object is facing right now, probably x axis or "forward vector"). Get the vector you want to be facing. Make sure both are normalized. Get the cross product of both Top slot is the original vector, bottom is the new facing vector. Then get the dot of them, again top slot is the original vector, the bottom is the new facing vector. Acos to degrees, then make rotator from axis and angle. This will yield a new rotation that you can use to ADD into an existing rotation. Key word here is add. You are adding this into an Existing Rotation.

Here's an image of my function.

alt text

tempue4image.jpg (99.2 kB)
avatar image Default816 Feb 25 '19 at 10:58 AM

Thanks a bunch man, this helped !

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Jun 30 '14 at 09:22 PM

avatar image

Thumper
956 137 147 385

avatar image Meowski May 13 '15 at 01:10 AM

Hi, any chance you could put up a screenshot of this solution? I'm having similar issues and am slightly puzzled at how you managed to solve it. Many thanks

avatar image Thumper May 13 '15 at 12:47 PM

Keep in mind that you have to set a true value to to these settings in the character.cpp

bUseControllerRotationPitch = true; bUseControllerRotationRoll = true; bUseControllerRotationYaw = true;

otherwise they'll forbid those movements from occurring to the character capsule.

alt text

upvectorzero.jpg (148.2 kB)
avatar image Meowski May 13 '15 at 02:47 PM

Thanks for that. I'm modifying an Actor's transformation directly so hopefully this should behave ok. I'm getting odd flipping around the poles (gimbal) so hopefully this can help with that. cheers

(comments are locked)
10|2000 characters needed characters left

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.

more ▼

answered Aug 30 '17 at 06:00 AM

avatar image

mightyenigma
3.7k 18 19 20

avatar image Darkentik Jun 25 '18 at 09:11 PM

This actually didn´t work in 4.19.1. I got weird flipping while manipulating the local rotation for looking up. I´m working on a network based spaceship movement according to adjust the spaceship to the mouse position on screen. It always ends up in gimal lock. So now i´m out of ideas how to fix this. The node "combine rotators" was a good hint but i actually don´t know how to get gimbal lock away. this is my solution now with gimbal lock. ue4gimballock

avatar image Nebula Games Inc Aug 01 '18 at 04:37 PM

Try this, I fixed gimbal lock on the flying pawn template

https://youtu.be/KqbqZ3IY1II

avatar image PropagandaWar Dec 05 '18 at 04:08 AM

Here's my 6 dof, used from various tuts etc. https://imgur.com/a/J2lEW. Attach your camera to a socket. I don't use camera's for any movement. It's silly.

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question