Detecting unit in front of a unit

satino

Member
Reaction score
4
I have a special spell that is instant cast and cause damage to a random unit in front of the caster at melee range but i have no idea how to detect the facing and position of a unit
 

keychup

Active Member
Reaction score
34
Set PointA = Position of Triggering unit
Set Group = Units within 100 of PointA matching Matching unit is alive/an enemy of owner of triggering unit/otherconditions
Pick Every unit in Group and do multiple actions:
-Set PointB = Position of Picked Unit
-Angle from PointA to PointB is Greater than or equal to Facing of Triggering Unit-20
-Angle from PointA to PointB is Less than or equal to Facing of Triggering Unit+20
-call RemoveLocation (udg_PointB)
call DestroyGroup (udg_Group)
call RemoveLocation (udg_PointA)
 

Juggernaut

I don't know what to change it to
Reaction score
33
I wanted to do similar spell. I did it similar to keychup but i got some problem, that when you attack the unit from above (go from above and use spell) then it wont work.
But it works if i go from sides/down
 

Tharius

Occasionally Around
Reaction score
39
Keep in mind that the game is looking for an angle value, i.e. a real number between 0 and 360. If the facing angle of the triggering unit is less than (for the example) 20, or greater than 340, it may not be able to properly detect the entire damaging area.

For example, say the facing angle of the unit is 355 degrees, and the angle from the casting unit (PointA) to the target (PointB) is 10 degrees. The target should be hit, because the actual difference in angles is only 15 degrees, but it won't detect a hit because 10 isn't between 335 and 375.

To get around this, you can use the modulo function, with (Facing of Triggering Unit + 20) or (Facing of Triggering Unit + 340) as the dividend, and 360 as the divisor.
 
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