# pitch in [-90,90]

Hi, i am trying to build a pitch meter for a flying game… The problem is that the pitch is between -90 and 90 with weird results. For example when going down the pitch first goes to -90 and afterwards increases again. I would prefer a 360 degree calculation or -180 to 180 in which i can see the difference between up or down. I read about quaternions, but i really can’t figure out how to visualize this correctly the way i want. Any workarounds currently? I only found topics with bugreports about it…

Hi ,

Unfortunately, what you are running into is Gimbal Lock, which is common with rotations, especially along the Y axis (pitch). This is not a bug but an expected behavior that must be taken into account when working with rotators. More information can be found here:

Additional information on quaternion math and spatial rotation can be found here:

There are several methods to get around Gimbal Lock, the easiest would be to rotate the actor along the X axis (yaw) as opposed to the Y axis (pitch). Another (significantly more difficult) would be to manually convert the rotator to a quaternion and then back to a rotator, which should allow you to work through Gimbal Lock and continue rotating correctly.

Are there any examples out there? this seems highly complicated for something which seems so simple.

If you are looking into c++ options, there is a possibility this will work:

Otherwise, it would be best to ask this on the forums in the blueprint scripting section, developers in the community may have some ideas that could help.

Thanks for all the help, C++ is not an issue. I will look into it!

I’m resurrecting an old thread here but I ran in to the same problem and wanted to add the solution that I found thanks to the above answer. It was a lot easier than I thought but basically all I did was reference the X value of an arrow that I rotated so that it was on the Pitch axis. That way I didn’t have to rotate my mesh which would have messed up the rest of the logic to drive my ship. Once I plugged that value in it was a perfect -180 to 180.