Support Forum

Path is chaotic, unsure how to fix this

Hello,

Very new to this, using A* Pathfinding Project Pro.

Level is a terrain, using a Recast Graph.

Yellow/Green line is the path generated. Cyan arrow is what I’d expect it to be. As you can see, the path is very chaotic, and doesn’t make sense.

In this scene, all the actors you see are not moving, and just the one selected is having it’s path calculated, there is no other movement happening at this point.

Any thoughts?

Hi

It looks like you might want to use teh Funnel Modifier.

See also https://arongranberg.com/astar/docs/modifiers2.html

Thank you. Indeed they do seem to find the shortest path now, but they also seem to be ignoring other actors as colliders, so they walk through them (or, really, push them out of the way), as seen below.

Screen Shot 2020-05-05 at 5.38.44 PM

When I have a lot of the compute at once (in this game, going from live movement to “turn based” movement, where only one would move at a time, all are moving at the start of this phase), they seem to all choose one of two paths which are not the most straight path.

Screen Shot 2020-05-05 at 5.41.00 PM

Hi

Pathfinding generally does not take other units into account. Usually you’d use local avoidance for that (https://arongranberg.com/astar/docs/local-avoidance.php).

For turn based games where the distance traveled is important I would recommend a grid graph instead. You might also be interested in this page: https://arongranberg.com/astar/docs/turnbased.html

Navmesh/recast graphs may not always return the most optimal path. The beta has some improvements to the funnel modifier to make it more optimal most of the time, but it’s still no guarantee.
You can read more about that at the bottom of this page: https://arongranberg.com/astar/docs/getstarted2.html#navmeshnotes

Thanks. I was under the impression that grid graphs were meant for flat surfaces, is that not correct?

Looks like local avoidance isn’t what I need, as in this case I don’t want the actor to slow down, but rather to walk around.

In the Unity NavMesh, there’s a “NavMeshObstacle” component – is there something similar that I can enable for non-moving actors so those that are moving know to go around?

Yes, grid graphs can have a non-flat surface.

You may find what you want here: https://arongranberg.com/astar/docs/turnbased.html