MultiTargetPath Doesn't Support Tag Constraints?

Hi,

I’m trying to start a MultiTargetPath that is constrained by tags, but it doesn’t seem to be working. Does my code look at least like it’s on the right track?

Note that I’m setting NNConstraint.tags to seeker.traversableTags to make it consistent with the constraints of my seeker. But it doesn’t matter what I set NNConstraint.tags to – the MultiTargetPath behavior is always the same. It always assumes all tags are suitable and only creates paths that avoid “unwalkable” nodes.

MultiTargetPath p = MultiTargetPath.Construct (transform.position, endPoints, null, OnMultiPathComplete);

NNConstraint nnConstraint = new NNConstraint ();

nnConstraint.constrainTags = true;
nnConstraint.tags = seeker.traversableTags; 

p.nnConstraint = nnConstraint;

seeker.StartMultiTargetPath (p);

Am I missing something here? Or is this a feature that MultiTargetPath simply doesn’t support?

Thanks so much for your time.

David

EDIT: Come to think of it, I don’t need to manually set NNConstraints when I use seeker.StartPath(). Is there just something fundamentally different about MultiTargetPath where it simply ignores tags?

Ok, I figured out what I needed to be doing. NNConstraints aren’t required for this. All you need is:

MultiTargetPath p = MultiTargetPath.Construct (GetFeetPosition(), endPoints, null, OnMultiPathComplete);
p.enabledTags = seeker.traversableTags;

seeker.StartMultiTargetPath (p);

Hi

Yeah… this is a slightly buggy behavior. I actually discovered that enabledTags on the path was not being set to seeker.traversableTags when a multi target path was started last week when I was cleaning up the Seeker code a bit. I added this comment and a note in my todo list.

// TODO: This method does not set the enabledTags or tagPenalties
// as the StartPath method does... should this be changed?
// Hard to do since the API has existed for a long time...

I think that in the next update I will change this, potentially adding an optional flag to the start path methods which specifies if those fields should be set to allow users to turn it off. It would be a breaking change, which I do not like, but I guess it is better than this inconsistency.

I created a MultiTargetPath like shown in the tutorial, but it was not using the traversable tags on my seeker, specifically it was walking right over GraphUpdateScene areas I had specified.

seeker.pathCallback = OnPathComplete;
seeker.StartMultiTargetPath(transform.position, endPoints, true);

TheoTower’s way of constructing the path fixed my issue and it respects the traversable tags. This was a helpful post, thank you!

MultiTargetPath p = MultiTargetPath.Construct (GetFeetPosition(), endPoints, null, OnMultiPathComplete);
p.enabledTags = seeker.traversableTags;
seeker.StartMultiTargetPath (p);

1 Like

I had the same problem with tagPenalties and MultiTargetPaths, which this solution fixed.

So another thumbs up from me!

I have made this change in my dev version now. So it will (probably) be included in the next release.