ConstantPath - Discarding tiles that are too close

I am developing a game where the player has to move a certain number of tiles away. The constant path seems to be exactly what i want. However it’s returning tiles in between the start point and the move distance. Provided the move distance is something like 5, how do i check the lengths of the node in the constant path list and discard any that are less than 5 away from the origin?

Any ideas? :slight_smile:
I can’t just check the distance of the point to the origin because that doesn’t take into consideration the distance of the actual walkable path?

Hi

Currently there’s nothing built-in that can accomplish this. However I suppose you could use two ConstantPaths, the first one with a max cost of N and the next one with N-1. Then you can figure out which nodes have a cost of exactly N by checking which ones are included in the first result, but not the second. There are other alternatives you can use, by supplying another callback to the ConstantPath, but that’s a bit more work.

The first solution was exactly what I needed, clever!

Thanks a bunch :slight_smile:

1 Like