A* Pathfinding Project

Can't traverse points on grid graph


Hey there.

I have in my game a very large grid graph that covers the walkable terrain. There are occasional graps in the graph that represent unwalkable terrain, such as bodies of water etc;
I am now trying to add an object that will allow players/npc to traverse these gaps, such as a bridge;
I’m using AIPath for handling the movement;

At first I tried using a point graph with the objects that make up the bridge as the points for the graph (using a tag: Bridge).
This failed, as although the points were created (and some were inside the grid graph area), the AI couldn’t find those points at all. Is there a way to make this work?

Next, I tried using Links. For test, I went to where I had generated a bridge, and manually placed two objects: one on each end of the bridge, and added a link component to one of them. Made sure both were inside the grid surface.

This succeeded in making the AIPath find the correct path towards the objective: however, it refused to move over it, and instead just danced around the first point. What’s the proper way to handle this? I’ve annexed an image that shows the current situation.

"however, it refused to move over it, and instead just danced around the first point. "

Does it’s next waypoint ever change to beyond the first link, or is it stuck always moving towards the first link’s tile?

I’ve not used these yet, but it sounds like it could be overshooting or such instead of moving to the next waypoint segment when close enough.
You could try tweaking a few settings in AI Path if that’s the problem.

Does it still do the same if you straighten the path by moving the first link nearer the edge of the bridge like the second link is?


It doesn’t. The line from the character to the point on the grid (the one between the character and the link itself) stays the same. The character will walk over it, and it won’t change to the link. It’ll walk close to it, and not change.

I’ll give this a try!


No good. I’m still using two graphs (the grid one, and the point one). I’ve disabled the renderer on the bridge, but you can see that there IS a connection between both areas, both in the form of the point graph and the link2.

The AI finds the connection, but still dances near that very point, getting very close to it, the distance changes, but he never goes past that point to aim at the next one.


Bump. Any ideas on how to get this to work? It is a vital piece for the game I’m working on. Currently had to expand the bridges to ridiculous widths to use the existing grid, but really need them to be narrower.



The AIPath script doesn’t have particularly good support for off mesh links, so while your approach with the NodeLink2 component will make it calculate a correct path, there are some things that can cause issues.

  • Firstly, if you have the ‘constrain inside graph’ setting enabled on the AIPath script, or you have the RVONavmesh component somewhere in your scene then the agent will be forced to be inside the graph which means it will never be able to leave the graph and go out on the bridge.
  • Secondly, if the agent recalculates the path while it is on the bridge, it may get confused because it is outside the graph. So then it will first try to move back to the graph and maybe later out on the bridge again.

If you have some way of detecting when the agent is traversing a bridge (an easy solution could for example be to use a trigger collider on the bridge) then you could make sure to disable path recalculation on the agent (canSearch property) and optionally ‘constrain inside graph’ (if you are using that).
I’m not quite sure if this will solve your issue because it’s hard to say exactly what causes the dancing around the target. But these steps are probably good to take either way.