MultiTargetPath Problems

Hi,

I have a position P.

I have N Targets T (some of which might be in non navigable areas… we have dynamic terrain)

I want to search for the target T that can be reached the quickest from P (the shortest path).

I only want the shortest so I’m setting pathsForAll = false

I collate all the positions of all Ts and send them to MultiTargetPath.

I notice that this is returning paths to Ts that are unreachable.

I require it to only return a path to a target position if it can get to that target position. This is the behavior I expected when we decided to buy the licence since I want to use it to find closest navigable targets of different types.

How do I achieve this? Is there a simple way I can ensure it either finds a navigable target or returns a null path?

Many thanks.

Hi

You mean that it is finding a path, but it only gets to a close position to the target and not exactly to the target?
By default this is the behaviour, if you want to change it, the easiest way is to set the NNConstraint on the path.

var path = MultiTargetPath.Construct(...);
path.nnConstraint = NNConstraint.None;

This will disable all searches for nodes that are close to the target point, but are not the closest.

Hi! Thanks for the quick response.

I wouldn’t use the word ‘close’ to describe how near the returned path gets to many of the targets! 5% of the way there on some, so ‘nowhere near’ is more like it. :smile:

It’s great that I can change the behavior as you suggest but this is still not perfect since I do actually want a path returned if the path can get within a certain threshold distance from the target.(very close, but maybe not on it)

Can I edit it so that I can chose the distance constraint to be considered ‘close’ to a target. That would be awesome.

Hi

Ah, actually I was going to suggest that change first, but then I changed my mind because I thought you really wanted it to be exact.

You can change the maximum allowed distance in A* Inspector -> Setting -> Max Nearest Node Distance.

Yay! Sorted. Cheers Aaron!

1 Like

Awesome that it works for you now!

Btw, when you have used the package for a while, a rating and/or a review in the Unity Asset Store would be greatly appreciated :smile:

I’ll definitely do that for you Aaron. I think you’re selling it cheap tbh.It’s saving me loads of time. I’m on a crazy schedule right now so I’ll do a write up after we get this prototype out ready for the GDC.

Hi

Thank you.
Well, it’s still one of the more expensive packages on the Unity Asset Store :smile:
Though I guess it is a lot larger than most of them.

How do I set MaxNearestNodeDistance on a per search basis?

I have many agents using all kinds of searches continuously, in several threads, so I’m thinking that I cannot simply change this parameter at the beginning of each search since it could screw up any of the other queued or currently processing searches.