• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

Getting closest unit

Status
Not open for further replies.
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)
 
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.
Back
Top