Get the difference between rotations
I'm working on a system where your character turns and depending on what rotation from an array is the closest to the current character's rotation, it will set the rotation to it.
However I'm struggling with the rotators and the math behind it. I can't find a way to get this working that takes into account the change from 0 to 360, or 180 to -180.
Is there a way to find the difference between rotations considering the change from 360 to 0 degrees?
asked Nov 20 '15 at 04:58 PM in Blueprint Scripting
Have you considered converting the values into Radians and doing the math that way? This way everything will be measured in fractions and multiples of Pi.
If you need to compare a rotation of 1 and 359 degrees, where the difference is 2, you would need to subtract 1 from 359, which would give you 358. This is obviously not correct unless you have a restriction on passing 360 and resetting. In this case, you can have a condition to check the difference and see if it is over 180. If it is, subtract 360 from it and get the absolute value of the new difference. This will result in 2. This should all be converted to Radians if you want pin-point accuracy though.
Hope this helps!
answered Nov 20 '15 at 07:54 PM
Matthew J ♦♦ STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here