Get AI Navigation Distances

Hello, I’ve recently begun working with the ENVQuery system, and although this isn’t critical to the issue, I’ve been trying to set up a ENVQ test that scores points based on the distance from an origin to several points in the world based on their distance PROJECTED ONTO A NAVMESH. For example, I don’t want an NPC set to patrol a small 100-unit-radius circle around itself walking around a long wall for five hours to a point on the other side just because the point was geometrically close by.

I’ve already looked into the source code for creating my own tests and understand it with no problems, but I’ve been unable to find a method for getting the AI nav distance between two points. Can anyone point me in the right direction? Also note that because ENVQTests exist only in C++, I’m looking for a code function/solution, but would still love to know if there’s an easy way to do it in blueprint.

Thanks so much for the help!

1 Like

I’m not an expert with C++, but there is an easy way to do it in blueprints. Specifically, the “Get Path Length” node allows you to provide two vector points and returns the navigation length. You could probably find out how it was made by looking at the source code.

Also, this may help as well:

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/AI/Navigation/UNavigationSystem/index.html

1 Like

That documentation is exactly what I was looking for. Much appreciated!