• 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.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

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