AIPath not moving for a couple of seconds (Only in build)

Hello there,

I have a problem that only happens when I create a build. I instantiate a group of enemies with an AIPath and Seeker script attached. It used to work perfectly fine, even before, but now when I create a build and they get instantiated, they just wait there for a random amount of time and they start moving one after another. The number of units I instantiate doesnt matter, they just wait randomly. I checked my PlayerLogs and found this message:

Path Failed : Computation Time 16,86 ms Searched Nodes 4471
Error: Canceled by script (Seeker.CancelCurrentPathRequest)
Path Number 3738 (unique id)
UnityEngine.StackTraceUtility:ExtractStackTrace ()
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
UnityEngine.Logger:Log (UnityEngine.LogType,object)
UnityEngine.Debug:LogWarning (object)
AstarPath:LogPathResults (Pathfinding.Path) (at D:/$ Raid Creator/Raid Lead/Assets/$ Assets/$ Tools/AstarPathfindingProject/Core/AstarPath.cs:835)
AstarPath:<InitializePathProcessor>b__122_1 (Pathfinding.Path) (at D:/$ Raid Creator/Raid Lead/Assets/$ Assets/$ Tools/AstarPathfindingProject/Core/AstarPath.cs:1301)
Pathfinding.PathProcessor:CalculatePathsThreaded (Pathfinding.PathHandler) (at D:/$ Raid Creator/Raid Lead/Assets/$ Assets/$ Tools/AstarPathfindingProject/Core/Misc/PathProcessor.cs:379)
Pathfinding.PathProcessor/<>c__DisplayClass24_0:<.ctor>b__0 () (at D:/$ Raid Creator/Raid Lead/Assets/$ Assets/$ Tools/AstarPathfindingProject/Core/Misc/PathProcessor.cs:110)
System.Threading.ThreadHelper:ThreadStart_Context (object)
System.Threading.ExecutionContext:RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)
System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)
System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object)
System.Threading.ThreadHelper:ThreadStart ()

I have no idea what causes this. I’d appreciate any answer.

Cheers!

Hi

Are you trying to recalculate the path every frame?

AIPath Screenshot

This is how all my AIPath.cs scripts are setup (except for max speed, radius and height).
I got an A* Pathfinder update panel every time I opened my project but I declined. This popup disappeared and I might have installed it because since it disappeared I got this weird bug or error going on… I have a not so good memory :sweat_smile:

Do you have any ideas what the cause might be? It only does not work in a build, but in the editor it works just fine…

Yes, but how do you set the destination for the agent? And do you recalculate the path using a script?

Hi, sorry for the late reply!

I call this Method in the update method:

public void SetDestination(Vector3 dest)
{
    if (aiPath == null) return;

    hasSetPos = true;
    aiPath.destination = dest;
    aiPath.SearchPath();
}

I even put a Debug.Log in this method and it debugged in the PlayerLogs that it called this method but then the error message from above appeared…

Hi

That means you ask it to discard its current in-progress path calculation and start from scratch. Every single frame.

I would suggest that you remove the aiPath.SearchPath() method call, and just let the agent decide for itself when it should recalculate the path.

1 Like