Support Forum

Finding multiple targets with end condition

Hi,

I have following scenario. I have dynamic objects in my scene for which I calculate which grid graph nodes they occupy (can be seen in screenshot as black squares). When I click the target object and I’m out of reach of the any of the target nodes, I want to evaluate path to distance x (skill use range) from that target node. With single target nodes I’ve usually used EndingConditionProximity. However, now that I want to check against all the node positions that are occupied, I have to make many path requests. In some cases some of those nodes are unreachable (and in this example multiple of them are), which causes me to request many paths that take maximum evaluation even from close distance.

image

To sort this out, I was planning that I could use MultiTargetPath to only get the shortest path. However, it seems that MultiTargetPath does not support ending conditions and therefore I couldn’t stop finding my path in the range I want to.

What would you suggest as best option to work in such scenario?

So, in practice I want to search multiple targets and pick the closest one but I also want to have proximity ending condition. And I’d like to do that without having to go into extremes with some paths, looking extremely long routes where there are none available. I was also thinking possible shortcuts in a way that I would maintain shortest currently found path as part of traversal provider which would likely minimize the hits, but then it’d be still bit about luck on getting path targets in good order and also the would need some distance information that I currently cannot seem to get in traversal provider.

I’m currently using A* Pathfinding Project Pro 4.3.40.

Hi

Hmm. I don’t think the MultiTargetPath can meet your needs. You could make an ABPath with an ending condition, just like you have done it now (destination = tree center), but make your ending condition check for the distance to any of the valid nodes. This would work pretty well, but it might not be 100% accurate. It might generate a path that is slightly slightly suboptimal due to the ABPath’s destination just being set to the tree’s center.

Thanks, that actually sounds something that would give good enough approximation for most cases, so will give it a try and see if the small error in precision is something that is not too clear for player.

1 Like