Setting path to end on node adjacent to target

I’m trying to use A* with a diablo 1/Darkeden 2D style movement using AI Lerp. I’m curious on which script I would need to edit (and any tips/pointers in editing the script) to cause the player/enemy stop on one of the nodes adjacent to the target’s position if the target is also a player/enemy rather than have the player/enemy occupy the same node as the player/enemy at the end of the path.

Any help would be greatly appreciated!

Hi

You could use a custom NNConstraint class to prevent the same node being chosen as the one the player is at.

This page might also be of interest: https://arongranberg.com/astar/docs/turnbased.html

Also see this thread for some code examples Nearest walkable with ITraversalProvider

1 Like

Thanks for the information Aron! Would the blockmanager with ItraversalProvider work with realtime, or is this limited to turn based? I’ll have to look into these!

Hi

It is intended for turn based games as it’s not very clear how the node blocks should be handled while agents are moving around. There is nothing preventing you from using it in real time, however I think you will quickly run into cases where it works less than optimally (e.g. two units coming from different directions start to traverse a single node at the same time).