[Solved] Get Group Center

Status
Not open for further replies.
Pick every unit in your unit group and sumarize their X and Y locations
Then divide both sums you just got by the total group size

And there you go! You just got X and Y values for the point which is the center of your unit group
Hope it helps :)
 
Why not:

get highest X/Y value
get lowest X/Y value

(highest - lowest) / 2 = center

Hmmmm, this would support bigger unit groups, but I don't think that the difference matters for practical purposes, unless you are making a 1 vs 1 million in war3... with actually 1 mil units on screen...

@xISLx 's method is simpler, works faster and is more accurate.

PS: Although, I like yours more :D
 
Hmm, to be honest I imagined this like Chaosy did with drawing rectangle example.
It supposed to be used in a game as a check if units are to stretched, so getting a center point with average distance to this center is what I'm trying to achieve.
On the other hand, looking at IcemanBo example maybe it will be smarter to just order this one unit (on point 100/100) to join the others? I have to think about this, however solutions are given. Thanks so much guys.
 
Status
Not open for further replies.
Back
Top