In NavMeshGenerator setting
clipLedges = false
helps with the infinite loop but Im not sure if its just moving the problem somewhere else yet.
With
clipLedges = true
theres two infinite loops on certain cells as mentioned above. When clicking the cell at a distance the infinite loop above shows up.
The other infinite loop occurs in buildNavigationPath in NavMeshPathfinder.java. when you are directly next to the cell and click it and not at a distance as in the above mentioned situation.
Edit: If you can visually see the cell or cells this infinite loop happens, you don’t have to be standing next to it. The other infinite loop is from a distance and I think findClosetCell chooses the cell.
while (currCell != null && currCell != endCell) {
inside the case statement
case SegmentsIntersect:
this statement is the problem.
} else {
// cannot fit directly.
// try to find point where we can
if (d1 < d2) {
intersectionPoint.interpolateLocal(wall.getPointA(), wall.getPointB(), distBlend);
newWayPoint = new Vector3f(intersectionPoint.x, 0, intersectionPoint.y);
} else {
intersectionPoint.interpolateLocal(wall.getPointB(), wall.getPointA(), distBlend);
newWayPoint = new Vector3f(intersectionPoint.x, 0, intersectionPoint.y);
}
It does something similar as the other loop but this time its bouncing back and forth where
d1 < d2
and next iteration its
d1 > d2
.
infinitely with the same point. Since the endCell is never reached the loop never ends.
Like I mentioned, Im not sure if setting
clipLedges = false
is just moving the problem somewhere else but I suspect this to be the case. I don’t think I can distill it down to a test case because of the complexity setting up navigation requires.
ill keep working on it and see if I can narrow it down more.