A* Pathfinding Project

Wavy path along edges of grid graph


#1

I am using a grid graph, and I am setting nodes to either walkable or not walkable, depending on a 2D texture mask that I create.

When I route my seeker through the graph, it takes the very shortest path, and kind of “waves” along the edges of the walkable nodes.

Is there a way I can have a cushion, or force the seeker to be more in the middle of the path?


#2

Hey,

If you are just looking to smooth the path, you can take a look at the modifiers https://arongranberg.com/astar/docs/modifiers.php

Not sure what the other requirements are for your game, but perhaps the Point Graph would work better for you here.


#3

Hi

You can use the “erosion uses tags” feature to make the nodes near unwalkable nodes have a higher penalty and thus make it move more in the center of the corridors.
See https://arongranberg.com/astar/docs/gridgraph.html#erosionUseTags

Alternatively, and this might be easier, you can add penalties directly to your texture mask using the Grid Graph -> Penalty Modifications -> Use Texture options.
See https://arongranberg.com/astar/docs/gridgraph.html#textureData

As @ToastyStoemp mentions, you can also use modifiers to make the path smoother.