I would like to find out how to find the closest X for pathfinding.
I have a player and a target, the target has an instance variable. On the layout I have 2 instances of the target.
What I want to do is get the player to move to the closest instance.
If I do a find path on the player, it seems to always move to the first instance or target regardless of how close it is.
So I flipped it around.
In order to do that I do a for each "Target", find path back to player. Then on the path found event of target, I save the number of nodes on each instance of the target.
Then I do a Find lowest instance of target using the instance variable and thus I can get the target with lowest nodes . I then pass that reference through to find path on player .
However sound this may seem, it doesn't work.
If there is another way to do it please feel free to shout it out.