# pitch in \[-90,90\]

**URL:** <https://forums.unrealengine.com/t/pitch-in-90-90/339972>\
**Category:** Community & Industry Discussion\
**Tags:** pitch, rotation, unreal-engine, question\
**Created:** [November 28, 2015, 8:09pm UTC](https://forums.unrealengine.com/t/pitch-in-90-90/339972 "2015-11-28T20:09:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_33d428af1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_33d428af1](https://forums.unrealengine.com/u/anonymous_user_33d428af1)\
**Post date:** [November 28, 2015, 8:09pm UTC](https://forums.unrealengine.com/t/pitch-in-90-90/339972/1 "2015-11-28T20:09:26Z")

</div>

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…

Example: [How can I create a day/night cycle in a small world? - Programming & Scripting - Epic Developer Community Forums](https://answers.unrealengine.com/questions/21168/pitch-limited-to-90-90.html)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b9532c9a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b9532c9a](https://forums.unrealengine.com/u/anonymous_user_b9532c9a)\
**Post date:** [December 1, 2015, 3:49pm UTC](https://forums.unrealengine.com/t/pitch-in-90-90/339972/2 "2015-12-01T15:49:42Z")

</div>

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:

> **[Gimbal lock](https://en.wikipedia.org/wiki/Gimbal_lock)**
>
> Gimbal lock is the loss of one degree of freedom in a three-dimensional, three-gimbal mechanism that occurs when the axes of two of the three gimbals are driven into a parallel configuration, "locking" the system into rotation in a degenerate two-dimensional space.
> The term gimbal-lock can be misleading in the sense that none of the individual gimbals are actually restrained. All three gimbals can still rotate freely about their respective axes of suspension. Nevertheless, because of the paralle...

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

> **[Quaternions and spatial rotation](https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation)**
>
> Unit quaternions, known as versors, provide a convenient mathematical notation for representing spatial orientations and rotations of elements in three dimensional space. Specifically, they encode information about an axis-angle rotation about an arbitrary axis. Rotation and orientation quaternions have applications in computer graphics, computer vision, robotics, navigation, molecular dynamics, flight dynamics, orbital mechanics of satellites, and crystallographic texture analysis.\[5 When used t...

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_33d428af1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_33d428af1](https://forums.unrealengine.com/u/anonymous_user_33d428af1)\
**Post date:** [December 1, 2015, 6:24pm UTC](https://forums.unrealengine.com/t/pitch-in-90-90/339972/3 "2015-12-01T18:24:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b9532c9a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b9532c9a](https://forums.unrealengine.com/u/anonymous_user_b9532c9a)\
**Post date:** [December 1, 2015, 6:28pm UTC](https://forums.unrealengine.com/t/pitch-in-90-90/339972/4 "2015-12-01T18:28:36Z")

</div>

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

> **[Get Quaternion (FQuat) from Vector](https://forums.unrealengine.com/showthread.php?78611-Get-Quaternion-%28FQuat%29-from-Vector&highlight=gimbal%2Block)**
>
> I know that you can easily get an FRotator from a Vector by doing Vector.Rotation() but how do I go about getting an FQuat? Thanks, Alex.

Otherwise, it would be best to ask this on the forums in the [blueprint scripting](https://forums.unrealengine.com/forumdisplay.php?6-Blueprint-Visual-Scripting) section, developers in the community may have some ideas that could help.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_33d428af1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_33d428af1](https://forums.unrealengine.com/u/anonymous_user_33d428af1)\
**Post date:** [December 1, 2015, 6:58pm UTC](https://forums.unrealengine.com/t/pitch-in-90-90/339972/5 "2015-12-01T18:58:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![DSutherland](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dsutherland/32/88710_2.png) [@DSutherland](https://forums.unrealengine.com/u/DSutherland)\
**Post date:** [March 4, 2019, 4:14pm UTC](https://forums.unrealengine.com/t/pitch-in-90-90/339972/6 "2019-03-04T16:14:44Z")

</div>

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.
