# Rotation negative after 180 degrees

It should automatically go from -179.999 to 179.999 or the other way around if you add more to the rotator…

e.g. : You’re at 0. If you now add 270 you’re at -90. That’s at least how it should work.

If your calculation is over 180 degrees, subtract 360 degrees from it, otherwise not.

Hi!
Im trying to compare the yaw of an actors rotation and a calculated yaw, once my actor reaches the calculated yaw I would like to actor to stop rotating…

However… my calculated yaw might be over 180 degrees (for instance it could be 270 dregrees or 360 or even more or anything in between)…
The problem is that once I retrive the yaw from my actor using Get Actor Rotation–>Break Rot–>Yaw… the yaw is always between 0-179.9999 or -179.999-0, so basically I would need a way to convert my calculated value into the same “format”… is it possible to some how simply “convert” the calculated value?

Br,
Inx

Then -179.999 is ~0 and 179.999 is ~360.0?

Im not sure if I did get you right :)… but I just tried your suggestion to substract 180 from the actors yaw, but that did not work… what I think I need is a way to turn my calculated yaw into the same “negative format” as the actors yaw once it reaches above 180 degrees.

ADDING 180, not subtracting.

When you have one actor from 0 - 360 and one from -179.999 - 179.999
you can either substract 180 from thefirst one or add 180 to the second one.

By subtracting, the 0 - 360 goes to -180 to 180 and the other way would be adding 180 and that would make -179.999 - 179.999 to 0 - 360.

The “~” was only a “ca.”, not a minus.

Hey!

It is a bug.

Maybe he doesn’t use Paper2D

If i am not mistaken this is a general problem.Dont know.It really looks identical to the problem i had.

Wasnt your Problem something with -130 to 130? So you were missing 100°? it seems normal that the range goes from -180 to +180. At least thats a circle i guess there are moments when a negativ value is usefull.

I still think he just needs to add 180 to this number so it 0 to 360.

im having a similar issue, i have a drone that tilts sideways on its Y axis depending on the Z rotation amount, however once it goes from 180 to a - value or the other way around from 50 to -50 as soon as the value becomes negative the Y axis jumps to the opposite side (instead of going smoothly as it does from 0 to 180, or even from -1 to -180)…

adding +180 to keep it as a positive value always did nothing if not make this even more buggy for me…

did you figure this out?

That will result in his rotation being backwards. The “zero” orientation would be 180o from the normal zero.

Instead, add 360 to the rotation if the rotation is < 0.

Begin Play:

• Save the rotation of the first actor.
• Call this function and save the angle.
On Tick:
• Call this function again and get the delta against first saved angle.
• Add this delta to the rotation Z (in my case) and then set the actors rotation to this final rotation.

You can use GetDenormalized() to convert an FRotator from the “-180 to 180” format into the “0 to 360” format

For example:

``float CurrentYaw = GetOwner()->GetActorRotation().GetDenormalized().Yaw;``
2 Likes

In the current version of Unreal Engine, there are a few nodes under the Rotator or Rotation section of the context menu in the Blueprint editor, which might fix this problem for you, and they let you choose whether to go the long way around or the short way. Likewise every blueprint node has a C++ function or object it corresponds to.
I believe I saw one that is specifically for the situation you’re describing.