LineCast always hits if no start node hint is provided

If i use NavMeshBase LineCast without a start node hint it returns always a hit.

NavMeshBase R:1280:
if (node == null || nn.distanceCostSqr > 0.001f*0.001f) {

In my case nn.distanceCostSqr > 0.001f*0.001f is always true.

But if i provide a startnode hint by:
var startNodeHint = navGraph.GetNearest(center).node;

the listcast works as expected and returns a hit if an obstacle was hit.
Maybe i’m missing something?

Hi

If you pass a hint, the origin will be clamped to the surface of that node.

It sounds to me like your original position is not actually on the navmesh.

Thx for pointing me in the right direction.
The issue was my terrain height.

1 Like