Support Forum

AIPath runs off PointGrid and gets stuck

AIPath getting stuck on a custom-built PointGrid (it is created gradually as the game runs). The seeker seems to find a path just fine, as seen in the first image, but then the “AIPath” script either stops in the middle of a doorway, or suddenly turns and moves into the center of a wall (where there are no connections).

Any ideas on what could be the cause of this behaviour?

When I place the walls and such I simply disconnect the nodes which they overlap with (the door is basically a connection between two points at its entrance/exit). Could it be that the character is for some reason pathing to a point that literally doesn’t have any other points attached to it?

I managed to get around the main issue by setting the Seeker “Start End Modifers” to Original. Though the AI still seems to trap itself into infinite loops frequently by suddenly switching out the perfectly fine path for a straight line to the objective, and try to walk through a wall to get out of the example room (turning back before reaching the wall, and repeat…)

Here the script decided to walk off the path for some reason, causing it to decide to travel through the wall instead. I don’t have any funnel or anything like that set, so I don’t know why the agent isn’t sticking to moving only from point-to-point?


Unrelated, but I’ve noticed the the pathfinding gameobject ‘bobbing’ upwards when walking over some of my nodes (the door, to be specific). Is this some sort of collision going on, and if so, can I disable it? I don’t really want 3d-physics in this game. Just running everything on pathfinding would be preferable.

Here are my current settings on the Seeker/AIPath

And here are the ones on the A* object. Since the Point Graph is code-generated the settings there are probably a bit funky, but I didn’t see anything I could change there to fix the Pathfinding agent.

Found a solution. Setting the nodes to “Walkable = false” makes the AI stop getting stuck on unconnected nodes.

I did try removing nodes as well using the Node.Destroy(), but this caused various indexing issues in the graphs own code, so I must have done that wrong. It probably wasn’t the way to go for this case anyway.

Is there a good way to use the path as ‘physics’ or something like that? I’ve managed to generate a second floor, and a ramp to it, but my character has trouble travelling up it.

I can somewhat get around the issue by enabling gravity, but if I do that the character starts ‘bobbing’ when it walks through doors and such.



Sorry for the late answer.
Generally I do not recomend relying on the path’s y coordinate too much. Instead using physics tols like raycasting usually works much better.
If you are using AIPath then it should just be a matter of having gravity enabled and making sure the appropriate ground colliders are in the layers indicated by the ground layer mask on the AIPath script.