• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

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