Fixed exception when planning results in an empty path.

WorldChunkRefactoring
Martin Felis 2023-11-01 12:34:28 +01:00
parent 0304b635a6
commit 5cabf4ca28
1 changed files with 6 additions and 1 deletions

View File

@ -163,7 +163,12 @@ public class NavigationComponent : Spatial
// Perform smoothing
_planningPathSmoothedWorldNavigationPoints = SmoothPath(body, _planningPathWorldNavigationPoints);
_planningPathSmoothedWorldNavigationPoints[0] = new NavigationPoint(fromPositionWorld);
// Ensure starting point is the current position
if (_planningPathSmoothedWorldNavigationPoints.Count > 0)
{
_planningPathSmoothedWorldNavigationPoints[0] = new NavigationPoint(fromPositionWorld);
}
}
public void FindPath(KinematicBody body, Vector3 fromPositionWorld, NavigationPoint navigationPoint)