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!):
-
Store the previous Forward vector, and get the current Forward vector
-
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)
-
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)
-
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!