I've been trying to use a grid graph for navigation in a tile-based 2D game but I'm really stuck on something that is probably simple.
My tilemap is offset by 0.5 on each axis so that the objects (sitting at integer positions) are always in the middle of any tile.
I generated a graph with the folowing options:
Node size: 1
Center: X0.5 Y0.5
Collision testing Ray
Now for testing I have set it up so the character will look for a path where the mouse is clicked, the resulting value is rounded so that it always points to the center of tiles.
The problem is that when I click on unwalkable areas then the path finding will return weird locations for the last waypoint, always pointing at the edge of the graph.
I would like for that to not happen and instead always stop at the last valid walkable tile.
Here's a picture of the wrong pathing: