A* Pathfinding Project

NullReferenceException occurs


#1

Following exception occasionally occurs during playing a game.

maybe after updating the library(from 4.1.12 to 4.1.16).

NullReferenceException: Object reference not set to an instance of an object
Pathfinding.TriangleMeshNode.GetPortal (Pathfinding.GraphNode toNode, System.Collections.Generic.List`1[T] left, System.Collections.Generic.List`1[T] right, System.Boolean backwards, System.Int32& aIndex, System.Int32& bIndex) (at Assets/OtherAssets/AstarPathfindingProject/Generators/NodeClasses/TriangleMeshNode.cs:340)
Pathfinding.TriangleMeshNode.GetPortal (Pathfinding.GraphNode toNode, System.Collections.Generic.List`1[T] left, System.Collections.Generic.List`1[T] right, System.Boolean backwards) (at Assets/OtherAssets/AstarPathfindingProject/Generators/NodeClasses/TriangleMeshNode.cs:318)
Pathfinding.RichFunnel.UpdateFunnelCorridor (System.Int32 splitIndex, System.Collections.Generic.List`1[T] prefix) (at Assets/OtherAssets/AstarPathfindingProject/Core/AI/RichPath.cs:366)
Pathfinding.RichFunnel.ClampToNavmeshInternal (UnityEngine.Vector3& position) (at Assets/OtherAssets/AstarPathfindingProject/Core/AI/RichPath.cs:554)
Pathfinding.RichFunnel.ClampToNavmesh (UnityEngine.Vector3 position) (at Assets/OtherAssets/AstarPathfindingProject/Core/AI/RichPath.cs:403)
Pathfinding.RichAI.ClampToNavmesh (UnityEngine.Vector3 position, System.Boolean& positionChanged) (at Assets/OtherAssets/AstarPathfindingProject/Core/AI/RichAI.cs:393)
Pathfinding.AIBase.FinalizePosition (UnityEngine.Vector3 nextPosition) (at Assets/OtherAssets/AstarPathfindingProject/Core/AI/AIBase.cs:548)
Pathfinding.AIBase.FinalizeMovement (UnityEngine.Vector3 nextPosition, UnityEngine.Quaternion nextRotation) (at Assets/OtherAssets/AstarPathfindingProject/Core/AI/AIBase.cs:509)
Pathfinding.AIBase.Update () (at Assets/OtherAssets/AstarPathfindingProject/Core/AI/AIBase.cs:326)

#2

Hi

Can you reproduce this exception reliably?
Are there any other exceptions logged earlier?


#3

I can reproduce it reliably (it occurs several times each play)

No exception but thousands of following warnings logged.

Path Failed : Computation Time 0.00 ms Searched Nodes 0
Error: Couldn’t find a node close to the start point
Path Number 4351 (unique id)
UnityEngine.Debug:LogWarning(Object)
AstarPath:LogPathResults(Path) (at Assets/OtherAssets/AstarPathfindingProject/Core/AstarPath.cs:758)
AstarPath:m__2(Path) (at Assets/OtherAssets/AstarPathfindingProject/Core/AstarPath.cs:1174)
Pathfinding.PathProcessor:CalculatePathsThreaded(PathHandler) (at Assets/OtherAssets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:358)
Pathfinding.c__AnonStorey1:<>m__0() (at Assets/OtherAssets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:95)
System.Threading.ThreadHelper:ThreadStart()


#4

The original exception was like this.
(I added 5 lines of code int TriangleMeshNode.cs to bypass exception in SharedEdge but it could confuse line numbers).

The following exception log is based on the original source.

NullReferenceException: Object reference not set to an instance of an object
Pathfinding.TriangleMeshNode.SharedEdge (Pathfinding.GraphNode other) (at Assets/OtherAssets/AstarPathfindingProject/Generators/NodeClasses/TriangleMeshNode.cs:304)
Pathfinding.TriangleMeshNode.GetPortal (Pathfinding.GraphNode toNode, System.Collections.Generic.List1[T] left, System.Collections.Generic.List1[T] right, System.Boolean backwards, System.Int32& aIndex, System.Int32& bIndex) (at Assets/OtherAssets/AstarPathfindingProject/Generators/NodeClasses/TriangleMeshNode.cs:326)
Pathfinding.TriangleMeshNode.GetPortal (Pathfinding.GraphNode toNode, System.Collections.Generic.List1[T] left, System.Collections.Generic.List1[T] right, System.Boolean backwards) (at Assets/OtherAssets/AstarPathfindingProject/Generators/NodeClasses/TriangleMeshNode.cs:313)
Pathfinding.RichFunnel.UpdateFunnelCorridor (System.Int32 splitIndex, System.Collections.Generic.List`1[T] prefix) (at Assets/OtherAssets/AstarPathfindingProject/Core/AI/RichPath.cs:366)
Pathfinding.RichFunnel.ClampToNavmeshInternal (UnityEngine.Vector3& position) (at Assets/OtherAssets/AstarPathfindingProject/Core/AI/RichPath.cs:554)
Pathfinding.RichFunnel.ClampToNavmesh (UnityEngine.Vector3 position) (at Assets/OtherAssets/AstarPathfindingProject/Core/AI/RichPath.cs:403)
Pathfinding.RichAI.ClampToNavmesh (UnityEngine.Vector3 position, System.Boolean& positionChanged) (at Assets/OtherAssets/AstarPathfindingProject/Core/AI/RichAI.cs:393)
Pathfinding.AIBase.FinalizePosition (UnityEngine.Vector3 nextPosition) (at Assets/OtherAssets/AstarPathfindingProject/Core/AI/AIBase.cs:548)
Pathfinding.AIBase.FinalizeMovement (UnityEngine.Vector3 nextPosition, UnityEngine.Quaternion nextRotation) (at Assets/OtherAssets/AstarPathfindingProject/Core/AI/AIBase.cs:509)
Pathfinding.AIBase.Update () (at Assets/OtherAssets/AstarPathfindingProject/Core/AI/AIBase.cs:326)