GetNearestBorder hit.tangentOrigin vs navmesh cut

Hi, I noticed strange behavior in the new GetNearestBorder function. According to the recast graph, it returns a tangentOrigin that’s perpendicular to the graph edge; however, when we get close to an edge formed by a Navmesh Cut, the tangentOrigin is returned incorrectly (it seems to be taken from the nearest edge of the graph itself instead). Is the intended behavior or a bug?

How it looks: https://i.gyazo.com/46a24aa630a1ec12c38e802c58a3015e.mp4

  • A* version: [5.4.4]
  • Unity version: [6.2]

Hi

Tangent origin should be a point on the edge, not a direction.

Do you mean the tangent field instead of tangentOrigin?

Ah, I see, it looks like I really confused the purpose of tangentOrigin. Thanks for the explanation!

By the way, just so I don’t have to create a new thread, is there any way to find the nearest point on the recast navmesh strictly vertically, rather than the actually nearest one? That would also be useful when using GetNearestBorder in some cases like using the navmesh as the base for collisions of a direct-control character controller.

Sure. You can do:

var nn = NearestNodeConstraint.Walkable;
nn.distanceMetric = DistanceMetric.ClosestAsSeenFromAboveSoft();
// Or nn.distanceMetric = DistanceMetric.ClosestAsSeenFromAbove();

var nearest = AstarPath.active.GetNearest(position, nn);

Take a look at ClosestAsSeenFromAboveSoft - A* Pathfinding Project for more info.

ClosestAsSeenFromAbove is exactly what you are asking for, but I would in most cases recommend ClosestAsSeenFromAboveSoft, as that will better handle the literal edge cases when the agent is just on the border of the navmesh.

Ah, that is super cool, thank you so much!