• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Need help with angle

Status
Not open for further replies.
Level 7
Joined
Jun 15, 2010
Messages
218
[real1]: Unit A facing angle
[real2]:Angle between Unit A and Unit B

What i need is that if Unit A faces Unit B with a max differnce of 8 degrees Then Boolean = True
Else Boolean = False

I tought it would be very easy, but the angles both work different

For the Units facing angle the angle works as following:

---------------------------- 270 degrees

180 degrees -------------------------------------0 degrees


---------------------------- 90 degrees



While for the angle between points is calculated as:


----------------------------------- -90
-0 ----------------------------------------------------------- -180
0 ------------------------------------------------------------- 180
------------------------------------- 90

Hopefully you understand. Else il try to explain with paint:p
 
Here is also an alternate equation.

set real3 = real2 - real1
if real3 < 0 then
set real3 = (real3 + (real3 * 2))
elseif real3 > 180. then
set real3 = 180. - real3
endif

if real3 <= 8. then <actions>
But it's much longer you might as well use DIMF's solution. ;_;

Note that 8 degrees is very small and hard to face in-game.
 
Level 7
Joined
Jun 15, 2010
Messages
218
ahh i tested it wrong. the angle between points is calculated as:
----------------------------------- +90
+180 -------------------------------------------------------------+0
-180 ------------------------------------------------------------- -0
------------------------------------- -90


So all i had to do was check if real2 is below 0 and then do set real2 = real2 + 360.


ty anyway guys:)
 
Status
Not open for further replies.
Top