• 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.

[Solved] Check if distance between 2 units is empty?

Status
Not open for further replies.

Chaosy

Tutorial Reviewer
Level 41
Joined
Jun 9, 2011
Messages
13,241
You could use the same method as triggering a knockback, except quicker.

In GUI there is a position function which goes something like:
position x offset by y in direction z

So you'd do

set dist = distance between unit 1 and unit 2
set ang = angle between unit 1 and unit 2
Loop 1-dist
set p = position of unit1 offset by 1 * integer a/b in direction ang
set g = unit group, units in 32 range of p
if g is not empty
unit found
Loop duration is not optimal in terms of performance, but you can tweak that after you got a base working
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,898
Adding to what Chaosy said, you could use something like this: Line Segment Enumeration .v2.1a

This system is great because all you need to do is define Point A (Pos of Unit A) and Point B (Pos of Unit B) and the Width. Then from there the system will add all of the found units to a Unit Group.

Then you want to create a Boolean "FoundUnit" and set it to False before you loop through the Unit Group. After that you would check each Picked unit in the Unit Group -> If picked unit is NOT equal to Unit A or Unit B then set FoundUnit = True. You'd probably want to filter out dead units and other stuff as well.

After the Pick every unit function you check the state of FoundUnit. If it's still False then you didn't find any units between Unit A and Unit B and can proceed to do whatever it is that you wanted to do.
 
Last edited:
Status
Not open for further replies.
Top