Hi There, I am trying to create an AI for a unit. In plain words it would be:
- Pick nearest enemy and go to him. But if you can't reach him (obstacles in the way), go to the second nearest.
If you look at the picture attached to this post, 1 should go to A, 2 to B and 3 to C. But currently 1 doesn't move because the command „pick nearest“ picks out D. How could I exclude D from the list of possible targets?
All the O are the same type of unit, and all the X are a different type of unit. The box which D is in might get destroyed, so it should still be targetable as soon as it is "reachable".
For the moment I am using
On mouse click
System > For each X
O > Pick Nearest to (X.x, X.y)
Find path to (O.x, O.y)
Move along path
As I said, it works perfectly, as long as a path can be found to the nearest target. As soon as a path cannot be found to the nearest target, the X doesn't move.
I would be very grateful if you could grant me some insight into a solution to this problem.