Assigning a modifier in advance for MultiTargetPath

Quick version of the question:
Is it possible to hook up a modifier (like a funnel) to a MultiTargetPath in advance so that it is handled inside its pathing thread?

Longer Explanation:
We have a very extensive AI system that senses key environment information in order to make smarter decisions when it is time to plan. We have our own nodes for cover and combat positions and each time the unit “senses,” we want a path to be calculated to all possible candidates within some detection range. This much is actually working fairly well, however, the issue has to do with the type of paths that are generated.

In order to accomplish our goal, we simply setup all the candidate node positions and start a MultiTargetPath. This is done independent of the unit’s seeker (which is being used for their actual movement), so we do it using the following:

var p = Pathfinding.MultiTargetPath.Construct(m_agent.CachedTransform.position,
positions, null,
HndOnPathComplete);

AstarPath.StartPath§;

This works very well since all the pathing is done in the Astar thread, however, none of the paths are modified in the thread. So we are getting the bare bones jagged paths when the callback is invoked. This means in order to get a better path, we have to stall the main thread to individually process each one using a funnel modifier inside the completion callback.

Is it possible to hook up a modifier (like a funnel) to a MultiTargetPath in advance so that it is handled inside its pathing thread? I couldn’t seem to track down how I might be able to go about this if it’s possible.

If this isn’t possible and you know any other ways we might be able to accomplish this task, please let me know.

Thanks!

Hi

You can assign a callback to the field called “immediateCallback”, that will be called on the pathfinding thread.
Inside that callback you should be able to post process the path (though some small modifications might be necessary to avoid calling the Unity API).

See http://arongranberg.com/astar/docs/class_pathfinding_1_1_path.php#a3a4d5d270f61f2caa0abc7268e754a46

Perfect, thank you!

Is it possible to apply a funnel modifier to a MultiTargetPath?

Do I need to somehow convert each underlying vectorPath into a Path and individually process each one? Or can the entire MultiTargetPath be sent to a funnel modifier?

I noticed that in your seeker implementation you skip post processing on MultiTargetPaths. Is that because it’s not possible?

Hi

If you look closer you will see that the Seeker receives a callback for each of the paths in the MultiTargetPath and sends it to OnPartialPathComplete. That will post process each inner path.

The reason it is done that way is because the funnel modifier modifies the path.vectorPath list and uses the path.path list.
What you can do is to loop through all the inner paths and assign the vectorPath and path fields to the values from the vectorPaths and paths (plural) lists and call the funnel modifier each time.

Ah, I see that now. Thanks!