Rotations are really hard to describe with only 3 elements (Roll, Pitch, Yaw) without running into Gimbal lock, that’s why using Roll Pitch Yaw in UE4 might give these ‘weird’ results after you’ve rotated in a certain way. (If you have also rotated objects from the inside the editor, you will know it happens very often)

If you’re also working with C++, using Quaternions or Rotation Matrices are directly available and you can convert from Rotators and back (from what I know, Quaternions & Matrices are very very limited in Blueprints).

If you’re working with blueprints, you can use the built-in functions to get the Forward, Up, and Right vectors from a given Rotator and use these vectors to determine whether someone turned their head left or right. A simple example on how this might work (not tested yet!):

1. Store the previous Forward vector, and get the current Forward vector

2. Cross product the previous forward with the current forward. (order matters in cross product and since Unreal uses left handed coordinate system we are using this order to compare with a reference up vector)

3. Dot product the result of step 2 with a reference Up vector (for example the world up vector (x = 0, y = 0, z = 1) or the local one)

4. If the dot product returns positive, then that means it was a Right turn. If it’s negative, it was a left turn. The problem becomes more complicated when it is zero. In that case you might want to change your reference up vector to use the local up vector or use Quaternions/Rotations Matrices that are readily available in C++.

Let me know how it goes!

Hi! I want to use the headset yaw as an input value. Looking left to right returns -90 to 90 as expect, but looking down makes the value suddenly jump to -170. This would make anything I’m controlling with this value also jump.

It’s understandable why this happens, once you look down far enough you’re slightly turning the headset upside down. But is there an alternative way to do it? I have been reading about using quaternions instead of rotators to avoid gimbal lock.

Here’s the blueprint and an example clip:

Any help would be appreciated, thanks!