I am currently using the A* Pathfinding Project Pro (version 5.1.6) in my Unity project and have encountered an issue where the Linecast
function seems to get stuck in an infinite loop, as indicated by the following error message:
“Linecast was stuck in infinite loop. Breaking.”
Here is the code that I’m using, which might be relevant:
public static class CalculateShortestPathDistance
{
public static async Task<Transform> CalculateAsync(Transform start1, Transform end1, Transform start2, Transform end2, Seeker seeker, bool debug = false)
{
var path1 = await GetPathAsync(seeker, start1.position, end1.position);
var path2 = await GetPathAsync(seeker, start2.position, end2.position);
if (path1 == null || path2 == null)
{
return null;
}
float distance1 = path1.GetTotalLength();
float distance2 = path2.GetTotalLength();
return distance1 <= distance2 ? end1 : end2;
}
private static Task<Path> GetPathAsync(Seeker seeker, Vector3 start, Vector3 end)
{
var tcs = new TaskCompletionSource<Path>();
seeker.StartPath(start, end, (Path p) =>
{
if (p.error)
{
//Debug.LogError("Pathfinding failed: " + p.errorLog);
tcs.SetResult(null);
}
else
{
tcs.SetResult(p);
}
});
return tcs.Task;
}
}
I have been trying to diagnose the problem, but I am unsure of what might be causing this behavior.
Thank you very much for your time and support.
Linecast was stuck in infinite loop. Breaking.
0x00007ff7bb99ffed (Unity) StackWalker::GetCurrentCallstack
0x00007ff7bb9a6cc9 (Unity) StackWalker::ShowCallstack
0x00007ff7bc9150e3 (Unity) GetStacktrace
0x00007ff7bcfabbcd (Unity) DebugStringToFile
0x00007ff7bab3c502 (Unity) DebugLogHandler_CUSTOM_Internal_Log
0x000001cc57a9c123 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)
0x000001cc57a9c03b (Mono JIT Code) UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object)
0x000001cc57a9bd80 (Mono JIT Code) UnityEngine.Logger:Log (UnityEngine.LogType,object)
0x000001cca2061ce5 (Mono JIT Code) UnityEngine.Debug:LogError (object)
0x000001cca202985b (Mono JIT Code) [NavmeshBase.cs:1314] Pathfinding.NavmeshBase:Linecast (Pathfinding.NavmeshBase,UnityEngine.Vector3,UnityEngine.Vector3,Pathfinding.GraphNode,Pathfinding.GraphHitInfo&,System.Collections.Generic.List1<Pathfinding.GraphNode>,System.Func
2<Pathfinding.GraphNode, bool>)
0x000001cca2028d23 (Mono JIT Code) [NavmeshBase.cs:1162] Pathfinding.NavmeshBase:Linecast (UnityEngine.Vector3,UnityEngine.Vector3,Pathfinding.GraphHitInfo&,System.Collections.Generic.List1<Pathfinding.GraphNode>,System.Func
2<Pathfinding.GraphNode, bool>)
0x000001cca2028ae5 (Mono JIT Code) [RaycastModifier.cs:324] Pathfinding.RaycastModifier:ValidateLine (Pathfinding.GraphNode,Pathfinding.GraphNode,UnityEngine.Vector3,UnityEngine.Vector3,System.Func2<Pathfinding.GraphNode, bool>,Pathfinding.NNConstraint) 0x000001cca202635b (Mono JIT Code) [RaycastModifier.cs:146] Pathfinding.RaycastModifier:Apply (Pathfinding.Path) 0x000001cca1ff78c9 (Mono JIT Code) [Seeker.cs:296] Pathfinding.Seeker:RunModifiers (Pathfinding.Seeker/ModifierPass,Pathfinding.Path) 0x000001cca202493b (Mono JIT Code) [Seeker.cs:336] Pathfinding.Seeker:OnPathComplete (Pathfinding.Path,bool,bool) 0x000001cca202481b (Mono JIT Code) [Seeker.cs:317] Pathfinding.Seeker:OnPathComplete (Pathfinding.Path) 0x000001cca20247c9 (Mono JIT Code) [Path.cs:876] Pathfinding.Path:ReturnPath () 0x000001cca2024778 (Mono JIT Code) [Path.cs:1127] Pathfinding.Path:Pathfinding.IPathInternals.ReturnPath () 0x000001c99d696e03 (Mono JIT Code) [PathReturnQueue.cs:61] Pathfinding.PathReturnQueue:ReturnPaths (bool) 0x000001cc78b36eb3 (Mono JIT Code) [AstarPath.cs:895] AstarPath:Update () 0x000001cca0d20cc8 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr) 0x00007ff90f31fe24 (mono-2.0-bdwgc) [mini-runtime.c:3445] mono_jit_runtime_invoke 0x00007ff90f25e764 (mono-2.0-bdwgc) [object.c:3066] do_runtime_invoke 0x00007ff90f25e8fc (mono-2.0-bdwgc) [object.c:3113] mono_runtime_invoke 0x00007ff7bb8c4db4 (Unity) scripting_method_invoke 0x00007ff7bb8a4654 (Unity) ScriptingInvocation::Invoke 0x00007ff7bb88d934 (Unity) MonoBehaviour::CallMethodIfAvailable 0x00007ff7bb88da22 (Unity) MonoBehaviour::CallUpdateMethod 0x00007ff7bb381108 (Unity) BaseBehaviourManager::CommonUpdate<BehaviourManager> 0x00007ff7bb3886ea (Unity) BehaviourManager::Update 0x00007ff7bb59a26d (Unity)
InitPlayerLoopCallbacks’::`2’::UpdateScriptRunBehaviourUpdateRegistrator::Forward
0x00007ff7bb580b8a (Unity) ExecutePlayerLoop
0x00007ff7bb580d16 (Unity) ExecutePlayerLoop
0x00007ff7bb586b09 (Unity) PlayerLoop
0x00007ff7bc4cedb9 (Unity) PlayerLoopController::UpdateScene
0x00007ff7bc4ccfbf (Unity) Application::TickTimer
0x00007ff7bc91b27a (Unity) MainMessageLoop
0x00007ff7bc91fb2b (Unity) WinMain
0x00007ff7bdca421e (Unity) __scrt_common_main_seh
0x00007ff987057374 (KERNEL32) BaseThreadInitThunk
0x00007ff98905cc91 (ntdll) RtlUserThreadStart