Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?

Product Version: UE 4.9
more ▼

asked Nov 20 '15 at 04:58 PM in Blueprint Scripting

avatar image

50 4 7 11

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hello Alex,

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!

more ▼

answered Nov 20 '15 at 07:54 PM

avatar image AlexHaddowMendes Nov 20 '15 at 08:14 PM

Hey, thanks for the answer! I'll do the research into Radians, this is pretty much the answer I was looking for.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question