Support Forum

Get nearest navmesh point on circle

Hello, I have two questions that are somewhat related.

First off, I know that is similar to Navmesh.SamplePosition - however, it’s not clear how to define a custom max distance for that check. I know NNConstraint has a bool that toggles whether it uses the global max distance, but I’m looking for a custom distance. Should I just modify that global value and then change it back after the check?

Second, my main question. Often I want to have a character keep a certain distance away from its target. In other words, on the edge of a “circle” around the target. I suppose one way to do this would be to run GetNearest a whole bunch of times around the character, but is there a faster way to do this?

Thank you!


The distance limit is global and controlled through A* Inspector -> Settings -> Max Nearest Node Distance. Currently there is no way to set a custom distance. However the easiest option is to just get the nearest point and then check if it is within the threshold. Otherwise you just discard it.

Yeah, that’s the easiest way I can think of.