Pathfinding suddenly breaks down at a random moment

We are using recast graph in our game and everything was working fine, but today we found out that sometimes pathfindings brokes with 999+ errors in just random moments. On the same game level mostly everything works fine, but sometimes it’s just brokes.

There is the first exception (appears randomly):

ArgumentNullException: Value cannot be null.
Parameter name: key
at System.Collections.Generic.Dictionary2[TKey,TValue].FindEntry (TKey key) [0x00008] in <47fc8c70fa834cbf8141d7c1a7589125>:0 at System.Collections.Generic.Dictionary2[TKey,TValue].get_Item (TKey key) [0x00000] in <47fc8c70fa834cbf8141d7c1a7589125>:0
at Pathfinding.RichFunnel.ClampToNavmeshInternal (UnityEngine.Vector3& position) [0x00197] in C:\Unity Projects\Hypercore-shooter\Assets\AstarPathfindingProject\Core\AI\RichPath.cs:607
at Pathfinding.RichFunnel.ClampToNavmesh (UnityEngine.Vector3 position) [0x00020] in C:\Unity Projects\Hypercore-shooter\Assets\AstarPathfindingProject\Core\AI\RichPath.cs:462
at Pathfinding.RichAI.ClampToNavmesh (UnityEngine.Vector3 position, System.Boolean& positionChanged) [0x00022] in C:\Unity Projects\Hypercore-shooter\Assets\AstarPathfindingProject\Core\AI\RichAI.cs:476
at Pathfinding.AIBase.FinalizePosition (UnityEngine.Vector3 nextPosition) [0x000ad] in C:\Unity Projects\Hypercore-shooter\Assets\AstarPathfindingProject\Core\AI\AIBase.cs:666
at Pathfinding.AIBase.FinalizeMovement (UnityEngine.Vector3 nextPosition, UnityEngine.Quaternion nextRotation) [0x0000f] in C:\Unity Projects\Hypercore-shooter\Assets\AstarPathfindingProject\Core\AI\AIBase.cs:627
at Pathfinding.AIBase.FixedUpdate () [0x00033] in C:\Unity Projects\Hypercore-shooter\Assets\AstarPathfindingProject\Core\AI\AIBase.cs:452

After this we have infinite numbers of NullReference:

(Filename: Assets/AstarPathfindingProject/Core/AI/AIBase.cs Line: 452)

NullReferenceException: Object reference not set to an instance of an object
at Pathfinding.RichFunnel.ClampToNavmeshInternal (UnityEngine.Vector3& position) [0x00133] in C:\Unity Projects\Hypercore-shooter\Assets\AstarPathfindingProject\Core\AI\RichPath.cs:589
at Pathfinding.RichFunnel.ClampToNavmesh (UnityEngine.Vector3 position) [0x00020] in C:\Unity Projects\Hypercore-shooter\Assets\AstarPathfindingProject\Core\AI\RichPath.cs:462
at Pathfinding.RichAI.ClampToNavmesh (UnityEngine.Vector3 position, System.Boolean& positionChanged) [0x00022] in C:\Unity Projects\Hypercore-shooter\Assets\AstarPathfindingProject\Core\AI\RichAI.cs:476
at Pathfinding.AIBase.FinalizePosition (UnityEngine.Vector3 nextPosition) [0x000ad] in C:\Unity Projects\Hypercore-shooter\Assets\AstarPathfindingProject\Core\AI\AIBase.cs:666
at Pathfinding.AIBase.FinalizeMovement (UnityEngine.Vector3 nextPosition, UnityEngine.Quaternion nextRotation) [0x0000f] in C:\Unity Projects\Hypercore-shooter\Assets\AstarPathfindingProject\Core\AI\AIBase.cs:627
at Pathfinding.AIBase.FixedUpdate () [0x00033] in C:\Unity Projects\Hypercore-shooter\Assets\AstarPathfindingProject\Core\AI\AIBase.cs:452

What can be wrong? We are using version 4.2.18.

Would you mind trying the latest version?

In case it can help. We have product that already released and updating versions of any assets is what we are usually trying to avoid. It was any changes in 4.2.19 that can fix it?

There’s nothing obvious I can find in the changelog. There are a few changes that could potentially be related, but it’s hard to say.

Ok, i’ll try, but don’t think that updating version will help :frowning: It’s not my first project with A* pathfinding and this is first time I encounter it. Looks like that there is something project related, but I don’t know what it can be. It’s always happening during the level, but we have cached (saved to file) scans and doesn’t recalculate during gameplay anything.

I tried, still have this issue :frowning: Played same level a 3 times and on 3rd tmie it broke :frowning:

Strange thing that it doesn’t happening at some point of time (like level start, or something like this). It’s happening randomly during gameplay, when nothing really changes.

We have a lot of Agents moving same time, idk maybe it can be the reason (can it be too much agents?), may be it’s have something with graph caching or multithreading of the A* implementation?

Now I see that this happens with agent that is standing with LOTS of agents near him and trying to go through very small passage. May be it’s somehow leading to this issue?

@aron_granberg sorry, can you check this thread, please? Very important issue for us, don’t know where to look and how to fix :frowning:

Ok, the problem was because sometimes Agents destionation is mathf.Infinity. Looks like a bug, because we do not set NaN or Infiinity destination.

Hi

The destination being set to +infinity is the default value. It indicates “no destination”. I don’t think this is the cause.

Are you sure this is the first exception? I cannot see how this one could possibly happen unless there were earlier exceptions.