I keep Getting Argument is out of range When NPC is near Edge


#1

Once in a while when an NPC is chasing the player and the player enters a no graph zone, this error occurs.

The NPC is near the edge of the graph, I don’t know if its because it fell out of the graph or what happens there, hope you can help me, thanks!

ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
System.Collections.Generic.List`1[Pathfinding.GraphNode].get_Item (Int32 index) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
Pathfinding.RichFunnel.SimplifyPath (IRaycastableGraph graph, System.Collections.Generic.List`1 nodes, Int32 start, Int32 end, System.Collections.Generic.List`1 result, Vector3 startPoint, Vector3 endPoint) (at Assets/AstarPathfindingProject/Core/AI/RichPath.cs:331)
Pathfinding.RichFunnel.BuildFunnelCorridor (System.Collections.Generic.List`1 nodes, Int32 start, Int32 end) (at Assets/AstarPathfindingProject/Core/AI/RichPath.cs:231)
Pathfinding.RichPath.Initialize (Pathfinding.Seeker seeker, Pathfinding.Path path, Boolean mergePartEndpoints, Boolean simplificationMode) (at Assets/AstarPathfindingProject/Core/AI/RichPath.cs:98)
Pathfinding.RichAI.OnPathComplete (Pathfinding.Path p) (at Assets/AstarPathfindingProject/Core/AI/RichAI.cs:219)
Pathfinding.Seeker.OnPathComplete (Pathfinding.Path p, Boolean runModifiers, Boolean sendCallbacks) (at Assets/AstarPathfindingProject/Core/AI/Seeker.cs:299)
Pathfinding.Seeker.OnPathComplete (Pathfinding.Path path) (at Assets/AstarPathfindingProject/Core/AI/Seeker.cs:267)
Pathfinding.Path.ReturnPath () (at Assets/AstarPathfindingProject/Core/Path.cs:728)
Pathfinding.Path.Pathfinding.IPathInternals.ReturnPath () (at Assets/AstarPathfindingProject/Core/Path.cs:782)
Pathfinding.PathReturnQueue.ReturnPaths (Boolean timeSlice) (at Assets/AstarPathfindingProject/Core/Misc/PathReturnQueue.cs:55)
AstarPath.Update () (at Assets/AstarPathfindingProject/Core/AstarPath.cs:792)

#2

I get a lot of these errors too, although I hadn’t realised it was related to the proximity of the nav edge. Here’s an example of mine (using AIPathAlignedToSurface):

ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
System.Collections.Generic.List`1[System.Int32].get_Item (Int32 index) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
Pathfinding.AIPathAlignedToSurface.InterpolateNormal (RaycastHit hit) (at Assets/AstarPathfindingProject/Behaviors/AIPathAlignedToSurface.cs:48)
Pathfinding.AIPathAlignedToSurface.UpdateMovementPlane () (at Assets/AstarPathfindingProject/Behaviors/AIPathAlignedToSurface.cs:64)
Pathfinding.AIPathAlignedToSurface.Update () (at Assets/AstarPathfindingProject/Behaviors/AIPathAlignedToSurface.cs:14)

#3

Hi

Interesting. I haven’t been able to replicate either of those errors. Would it be possible for you to share a test scene with me in which it is possible to replicate it easily?


#4

I’m trying to make a test scene where the error can be replicated in the meantime this is the code I get.

ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
System.Collections.Generic.List1[Pathfinding.GraphNode].get_Item (Int32 index) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:633) Pathfinding.RichFunnel.SimplifyPath (IRaycastableGraph graph, System.Collections.Generic.List1 nodes, Int32 start, Int32 end, System.Collections.Generic.List1 result, Vector3 startPoint, Vector3 endPoint) (at Assets/AstarPathfindingProject/Core/AI/RichPath.cs:331) Pathfinding.RichFunnel.BuildFunnelCorridor (System.Collections.Generic.List1 nodes, Int32 start, Int32 end) (at Assets/AstarPathfindingProject/Core/AI/RichPath.cs:231)
Pathfinding.RichPath.Initialize (Pathfinding.Seeker seeker, Pathfinding.Path path, Boolean mergePartEndpoints, Boolean simplificationMode) (at Assets/AstarPathfindingProject/Core/AI/RichPath.cs:98)
Pathfinding.RichAI.OnPathComplete (Pathfinding.Path p) (at Assets/AstarPathfindingProject/Core/AI/RichAI.cs:219)
Pathfinding.Seeker.OnPathComplete (Pathfinding.Path p, Boolean runModifiers, Boolean sendCallbacks) (at Assets/AstarPathfindingProject/Core/AI/Seeker.cs:299)
Pathfinding.Seeker.OnPathComplete (Pathfinding.Path path) (at Assets/AstarPathfindingProject/Core/AI/Seeker.cs:267)
Pathfinding.Path.ReturnPath () (at Assets/AstarPathfindingProject/Core/Path.cs:728)
Pathfinding.Path.Pathfinding.IPathInternals.ReturnPath () (at Assets/AstarPathfindingProject/Core/Path.cs:782)
Pathfinding.PathReturnQueue.ReturnPaths (Boolean timeSlice) (at Assets/AstarPathfindingProject/Core/Misc/PathReturnQueue.cs:55)
AstarPath.Update () (at Assets/AstarPathfindingProject/Core/AstarPath.cs:792)


#5

Today I find out that one of the errors is related to the RVO system and the other to the “Funnel Simplification” option in the “Rich AI” script.
I hope this information might be useful.


#6

I made a simple test scene to show the exceptions. I have not yet heard from Aron about this, not even whether he could reproduce the exceptions. I’d appreciate someone else on this thread trying my test and confirming that they too also see the exceptions (it happens when the player object warps from the cave to the surface in scene1).


#8

I can confirm the error appears every single time.


#9

Hi

Do you have an example scene I could try out @Toto. I haven’t been able to replicate that exception.
I have managed to fix the exception that @Snouto talks about, but it is unfortunately completely unrelated.


#10

After several fail intents, we have decided not to use RVO system and try other alternatives to avoid NPCs to collide with each other.