HI there,
I am having trouble in using GetNearestForce or GetNearest with or without constraints to find a precise position from one point to a point on the graph. I have had all sorts of combinations but this is the code I was using in general:
public Vector3 GetNearestForcePosition(Vector3 position) {
NNConstraint constraint = new() {
walkable = true,
distanceXZ = true,
constrainWalkability = true
};
return (Vector3)graph.GetNearestForce(position, constraint).node.position;
}
In the following screenshot one can see 5 units and the red spheres mark the aiPath.destination. For the two on the left I am using the upper method to find a position on the blue GridGraph because otherwise it would be on the same height as the others.
For some reason for the second left one it is working for the left most it is not. Generally, GetNearestForce is returning very inconsistent results. I tested with different graphs, with different node sizes and slope steepness.
Those are my Graph settings: