Some problems regarding FunnelModifier/StringPulling on GridGraph

  • A* version: 5.3.3
  • Unity version: 6000.0.36f1

In a somewhat rare case, I need to use GridGraph for patfinding on a continuous world. To make paths seem more natural, I use a modified version of FunnelModifier, which in turn uses GridStringPulling. To make matters more complicated, I need to support non-point agents. So, the first question:

  1. How hard would it be to add an agentRadius parameter to FunnelModifier to make it generate points not at corner of obstacles, but with an offset, so that agents wouldn’t clip corners when moving alon the calculated path? As far as I understand, the problem is very complicated in a general case. My case is simpler - agentRadius is always <= 0.5*cellSize, so at worst the path should go through the center of the cell.

For now, I apply additional post-processing that tries to move corner points away from, well, corners. It’s a super-complicated set of crutches and work-arounds for corner cases, which grows more complicated every day (for example, handling “thin walls” is its own special kind of pain). It’s complicated further by the fact that GridStringPulling sometimes (often) produces points which, when queried for nearest node, return the node that contains the obstacle. This is understandable: a corner point really “belongs” to all four cells around it, so it’s not unexpected that, when queried, the graph might return any one of them. However, this makes my task very, very hard, because I need to calculate the direction of offset away from the corner, and if the point is inside the obstacle, the algorithm will choose the wrong direction, inside obstacle. Mind you, I use the term “obstacle” loosely here, because it might be a walkable cell, which just doesn’t have a direct connection to other cells in path. This happens near “thin walls”, and especially bad near “balconies” where two adjacent walkable nodes might have a great different in height. I can’t use Area ID check to weed this case out, since they often belong to different parts of the same area. Which leads me to

  1. Can GridStringPulling be modified to at least return a point that is guaranteed to be inside a cell that “belongs” to path?

I’ve been banging my head against this problem for past several months. But maybe I need a completely different approach? In that case, any advice would be welcome, too.

This gets pretty deep into some of the stuff that Aron definitely would know since he’s had to wrangle with it himself of course. I’ll tag him in this to take a look at when he gets the chance :slight_smile:

Short answer: no.

I’ve been attempting to implement this multiple times in different ways. However, it turns out that there are so many extremely intricate edge cases that it never works quite well.

The much more robust solution is to adjust the path following behavior to keep away from walls. This is what the FollowerEntity script does.

For very small offsets you could use the RadiusModifier. But it will not be robust for anything other than simple cases.

I see. A pity, because “keep away from walls” results in less-optimal paths (if it nears a wall, it will “hit” it and then follow along, instead of going straight for the corner). I guess I’ll keep developing my pile of workarounds then.

It should not “hit it”. It definitely takes the next corner into account, and will move to the right position direclty.