Getting closest unit

Status
Not open for further replies.
Level 13
Joined
Sep 14, 2008
Messages
1,408
IF you want to make in in GUI do it like tihs:

- need variable "distance" = 0 (start value)
Pick random unit in playable map area and do:
set "distance" = distance between position of "yourUnit" and position of "picked unit"

Pick all units in playable map area and do actions:
if(distance between position of "yourUnit" and picked unit < "distance")
set distance = distance between position of "yourUnit" and position of picked unit


That will get the closest unit BUT it will cause lag if too many units are around :/

should be only used for things like scroll of townportal :/ (like in dota)
 
Level 10
Joined
Sep 29, 2006
Messages
447
Actually what I am trying to do is pick the closest unit within the current camera bounds. However, I am using a third person camera so I don't know If using current camera bounds would give me all the visible units. Basically I need to storm bolt the closest visible enemy in these camera bounds:

Picture1-1.png
 
Status
Not open for further replies.
Top