A* Pathfinding Project

Unexpected jumps/snapping between overlapping point graphs


Hi! I’m having a problem with using several point graphs to define the path in a simple 2D game. I’ve defined a different point graph for every floor in the game (sometimes they overlap, like the red and green graphs here) and connected them via the yellow nodes (using NodeLink):

When the player walks on those, the character’s sorting order is set to the destination node’s sorting order, in order for the player to appear behind the stairs. The problem is, sometimes there are some strange jumps and the player doesn’t pass through the connector node (even though no connections between those two graphs exist except the yellow connector node) so they end up in front of the stairs. The Seeker is currently set to Node Center (Snap to Node) on the start and end node.

I’d appreciate your help!



Sorry for the late answer.
I think what is happening in these cases is that the player did a path recalculation. When a path recalculation is done it will find the closest node as the starting point. If another node (possibly on another graph) was closer then, it will move to that node.

I’m not quite sure how your game works, but you might want to restrict your agents to only use a particular graph by changing the graph mask on the Seeker component.


Thanks for your reply, Aron! That sounds like a good reason why this behavior might be occurring. However, I don’t think I can restrict the characters to only use a specific graph at a time, because they’re supposed to be able to choose which graph to traverse based on where the user clicks. This is because each point in a graph is designed to be only accessible via one of the two graphs located at an intersection.

Do you have any suggestion in that case? I’m thinking perhaps I could “force” the character to navigate to an intersection node once they’re on one of the graphs concerned, but how can this be done? Would this work if I simply add the intersection node to the path manually?