NullReferenceException : Pathfinding.PointGraph.GetNearest

Hi,

My customer got this kind of error :

NullReferenceException: Object reference not set to an instance of an object.
at Pathfinding.PointGraph.GetNearest (UnityEngine.Vector3 position, Pathfinding.NNConstraint constraint, System.Single maxDistanceSqr) [0x00036] in :0
at AstarPath.GetNearest (UnityEngine.Vector3 position, Pathfinding.NNConstraint constraint) [0x00102] in :0
at Pathfinding.OffMeshLinks.ClampSegment (Pathfinding.OffMeshLinks+Anchor anchor, Pathfinding.GraphMask graphMask, System.Single maxSnappingDistance, Pathfinding.OffMeshLinks+Anchor& result, System.Collections.Generic.List`1[T] nodes) [0x0003c] in :0
at Pathfinding.OffMeshLinks.Refresh () [0x0014c] in :0
at Pathfinding.WorkItemProcessor.ProcessWorkItems (System.Boolean force, System.Boolean sendEvents) [0x00137] in :0
at Pathfinding.WorkItemProcessor.ProcessWorkItemsForUpdate (System.Boolean force) [0x00000] in :0
at AstarPath.PerformBlockingActions (System.Boolean force) [0x0002b] in :0
at AstarPath.Update () [0x0001b] in :0

Do you have any tips on this ? My PointGraph maxDistance = -1 because I am adding nodes manually and creating links between TriNode & PointNode.

Best

Same error but in a different usecase :

NullReferenceException: Object reference not set to an instance of an object.
at Pathfinding.PointGraph.GetNearest (UnityEngine.Vector3 position, Pathfinding.NNConstraint constraint, System.Single maxDistanceSqr) [0x00036] in :0
at AstarPath.GetNearest (UnityEngine.Vector3 position, Pathfinding.NNConstraint constraint) [0x00102] in :0
at Pathfinding.Path.GetNearest (UnityEngine.Vector3 point) [0x00000] in :0
at Pathfinding.ABPath.Prepare () [0x00000] in :0
at Pathfinding.Path.Pathfinding.IPathInternals.Prepare () [0x00000] in :0
at Pathfinding.PathProcessor.CalculatePathsThreaded (Pathfinding.PathHandler pathHandler, Pathfinding.BlockableChannel`1+Receiver[T] receiver) [0x00091] in :0

Best

Hi,
I think that it could be related to the option OptimizeForSparseGraph but why nodes are not found in this case ?

Best

Hi

There was indeed a bug there.
I will include a fix in the next update.