Constrain angle to between -180 and 180

I’m at a bit of a coders block, and I’m sure it’s quite simple. :stuck_out_tongue:

I tried using the following:

((angle-180)%360) + 180

But for angles < 180 degrees, it works just fine, but after that it get’s a little funny. I know why it’s doing that, I’m just looking for a way to fix it.

Is there any way to do it quickly without 6 lines of codes containing if statements? The code should be as efficient as possible.