Rotation value gets changed automatically from 270 to -90

Hi!
I try to build a tool to create a modulate mesh. It basically snaps one mesh to another and I can do some other things with it. But I have a problem when I try to build a curve. The rotation value gets changed. In my code I pass the value 270°, but my mesh gets rotated to -90°. This is not a big deal, but for my next curve I add the next 90 degrees, which results wrong. The previous 90 degree rotations work fine. 0 + 90 = 90. 90 + 90 = 180. But suddenly 180 + 90 = -90 for the engine.
The funny thing is, that in the editor it is even not possible to give the rotation a negative value. It is clamped from 0 to 360.

    //...some math
    //rotZ is 270 during debugging
    someActor->SetActorLocationAndRotation(location, FRotator(0, rotZ, 0));

I pass 270 to the function but the result is -90 (see image)

271406-annotation-2019-03-14-185531.jpg

Has anybody any idea why this happens?

Thank in advance!

PS: I’m not in Game Mode. My code is executed in virtual void OnConstruction(const FTransform& Transform).

I believe this is caused by shortest path. 0 → -90 is shorter than 0–> 270.

Anything above 180 will therefore be negative as the true range is 180 to -180. Not sure what you mean by the engine not handling negative rotations, it certainly does but it counts them as equal. -1 is equal to 181 and so on.

For your issue of addition an if swap should solve it. I know it’s annoying but it’s a quick fix. So, if the value you are trying to add to is negative, multiply added value by -1. If you are trying to subtract it will then add so works both ways.