Path Ending on un-walkable node (2D)

Good day!

I have set up (hopefully correctly) a 2D project to figure out how I would work out some pathfinding issues that I have in another project.
I tried different colliders on the obstacles and for some reason, the colliders don’t seem to be setting up unwalkable nodes properly. When I do get the unwalkable nodes seemingly placed correctly, my character still seems to walk into the unwalkable node.

I am moving the character via transform.Translate, since it’s a 2D object. I initially thought I had to have some physics on my character to use collision detection, but on further investigation, I don’t think that’s the issue, since I can click in the middle of a red square (unwalkable) and the system will find a path to that note. I assume that if the node is not walkable, then the system would not return a path in the first place (please correct me if I’m wrong about that).

Any help to figure out this issue would be greatly appreciated!




Bump?

Hi

Try to change the settings for the Seeker->StartEndModifier->EndPoint. The best setting for your project would probably be SnapToNode or ClosestOnNode.

PS: Sorry for the late answer, I have been away for a while

1 Like

That definitely made it a lot better. Thank you!

Two more questions…

a) Is there a way to not return a path if the end point is in an un-walkable node?

b) In the same vein, if I do tap on a “building” (which obviously is not walkable) is there a way to force the path to the bottom (or wherever the door is) of the building?

Thanks again!

Hi

a) You can decrease the A* Inspector -> Settings -> Max Nearest Node Distance. If it cannot find a walkable node within that distance, the path request will fail.

b. Not really. The best way would be to define an “rally point” for the building and direct all paths targeting it to that point instead of to the centre of it.