- Joined
- Jul 22, 2015
- Messages
- 3,485
Is there a way to check where the closest region is to a unit and to order them to move there?
Do you want to check for the closest center of region?
You would have to keep track of the orders of the unit.
I think hashtables would be a good solution. Then store a variable with the region the unit was ordered to move at and check if a unit stops moving ( I think there is a system in the spell section for this), then load the stored variable and order the unit to go there.
If you have a few unit I would recommend using indexed variables instead.
When the unit is ordered to move to a point, save that point as a variable, and when the unit stops, then order it to move to the variable point again and clear the leak.
Is it for a TD ?
Well, using hashtables would solve the issue. Store every wave unit in the hashtable and the point where it is moving to and once it stops moving, then order it to move to the coordinates you load from the hashtable.