Angle Comparison Issue

Danis[h]

New Member
Reaction score
19
Angle Comparison Issue [RESOLVED]

Solved

Okay, so basically what I'm trying to do is this: I want the game to detect whether or not a rotating unit is facing towards a unit in passing when it runs by..

Basically, the players have to follow a path, and if the "sentry" (in this case a banshee) they run past is facing towards the spot they're running by, I want the game to react.. yet I can't seem to get the angle comparison right.

This is what I've got so far.
Trigger:
  • Banshee one
    • Events
      • Unit - A unit enters Banshee 1 <gen>
      • Unit - A unit enters Banshee 2 <gen>
    • Conditions
    • Actions
      • For each (Integer A) from 1 to NumBanshee, do (Actions)
        • Loop - Actions
          • Set TmpPoint[5] = (Position of (Triggering unit))
          • Set TmpPoint[6] = (Position of Banshee[(Integer A)])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between TmpPoint[5] and TmpPoint[6]) Less than or equal to 350.00
              • (Facing of Banshee[(Integer A)]) Less than or equal to ((Angle from TmpPoint[5] to TmpPoint[6]) + 20.00)
              • (Facing of Banshee[(Integer A)]) Greater than or equal to ((Angle from TmpPoint[5] to TmpPoint[6]) - 20.00)
            • Then - Actions
              • Game - Display to (All players) the text: Works
            • Else - Actions


Trying to compare the angle between the two points (position of unit entering region, to position of senty (banshee) and then the facing of the banshee.

NOTE: I am going to remove the locations, once I've got this working.

Update: I'm assuming it calculates the angle in relation to the x-axis which would explain why the above comparison wasn't working. Now I just don't know how to make the comparison
 

Danis[h]

New Member
Reaction score
19
the angle from 5-6 is different than the angle from 6-5

Yea, I wanted it to work if the angle was in-between those two values.
So lets say that angle 1 is 40
then if angle two is in-between 20 to 60, it should work.

if this is not what you meant, could you please specify it more clearly? I'm a bit at a loss on this issue.
 

SaintMorose

New Member
Reaction score
26
problem with angles is 350 + 20 = 10 which may be part of it

my question is you want it to say Works if the Banshee is facing triggering unit or facing the opposite direction?
 

Danis[h]

New Member
Reaction score
19
problem with angles is 350 + 20 = 10 which may be part of it

my question is you want it to say Works if the Banshee is facing triggering unit or facing the opposite direction?

I want for it to work only when the banshee is facing towards the triggering unit.
 

SaintMorose

New Member
Reaction score
26
Trigger:
  • * Set TmpPoint[5] = (Position of (Triggering unit))
    • * Set TmpPoint[6] = (Position of Banshee[(Integer A)])


should read

Trigger:
  • * Set TmpPoint[6] = (Position of (Triggering unit))
    • * Set TmpPoint[5] = (Position of Banshee[(Integer A)])
 

Danis[h]

New Member
Reaction score
19
Trigger:
  • * Set TmpPoint[5] = (Position of (Triggering unit))
    • * Set TmpPoint[6] = (Position of Banshee[(Integer A)])


should read

Trigger:
  • * Set TmpPoint[6] = (Position of (Triggering unit))
    • * Set TmpPoint[5] = (Position of Banshee[(Integer A)])

didnt seen to work. Does anyone else have any suggestions?... The angle the banshee is facing is not fixed, it changes all the time.

update:
Okay so here is an attempt at a visualization of the issue. I am assuming that warcraft III calculates a facing angle, and the angle between two points relative to the x-axis. This assumption is made because warcraft 3

So assuming I have two points “A” and “B.” Point A is the point of my triggering unit and B is the position of the banshee. The angle between these two points I’ll name “u”
Now I have a second angle, which will be the facing angle of the banshee. This angle I’ll name “v”.
angle.jpg

Now from this image, the facing angle of the banshee at B is definitely not pointed towards A. What I need now though is a way to see whether or not v is pointed in the general direction of the position A.
I’m trying to do this by comparing the two angles, but I’m stuck on the issue.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top