AIPath Agent not navigating in build (v5.3.8)

  • A* version: 5.3.8
  • Unity version: Tested on 2021.3.45, 2022.3.62

Hi there! I’ve been working with Astar on a project for a few years. I recently updated to 5.3.8 while working on some new navigation features for this project, and have just now noticed that pathfinding agents don’t seem to be successfully finding paths on any of my Recast graphs specifically in builds. I’ve gone through several debugging steps (adjusting the way that my graph is scanned, testing with older versions of my agents, updating Unity, etc) and have arrived at a point where I can’t figure out where to go: I’ve created a fresh project (2022.3.62), installed A* and the example scenes, and attempted to build the RecastMoving scene to test the package’s base functionality. This scene works as expected in the editor (the little agent follows my mouse around) but on build, the agent remains completely still. Is this an error with the current A* version, or is there a new build setting I need to adjust in order for A* to build successfully?

What movement script are you using? I had a similar problem, but I’m not sure if it’s related.

In my case, I was using FollowerEntity, and I had recalculate path frequency set to “Never,” as the paths never needed to change. With this setting, however, the agents wouldn’t move at all. I changed it to use some very long time instead, and it began working. I have no idea why.

As part of troubleshooting this, I’ve been trying to break down the process of scanning + finding a path in my project. I’ve noticed a few things:

  • The actual process of scanning / baking / loading the graph seems to be entirely error-free. When I check any information about a graph at runtime, it’s the same as the information available in the editor.
  • Agent pathfinders in my project (which extend from AIPath and don’t modify anything about its pathfinding process) don’t seem to have issues deciding when to calculate a new path. They’re storing all the requisite information correctly (current position, end position, last calculation time, etc).
  • When enabling pool-related debugging, I’m getting two different warnings in editor and at runtime. It seems likely that these are related to the errors I’m experiencing:

[In editor]

A path was calculated, but no callback was specified when calling StartPath. If you wanted a movement script to use this path, use ai.SetPath instead of calling StartPath on the Seeker directly. The path will be forwarded to the attached movement script, but this behavior will be removed in the future.
UnityEngine.Debug:LogWarning (object,UnityEngine.Object)
Pathfinding.Seeker:OnPathComplete (Pathfinding.Path,bool,bool) (at ./Packages/com.arongranberg.astar/Core/AI/Seeker.cs:361)
Pathfinding.Seeker:OnPathComplete (Pathfinding.Path) (at ./Packages/com.arongranberg.astar/Core/AI/Seeker.cs:327)
Pathfinding.Path:ReturnPath () (at ./Packages/com.arongranberg.astar/Core/Pathfinding/Path.cs:876)
Pathfinding.Path:Pathfinding.IPathInternals.ReturnPath () (at ./Packages/com.arongranberg.astar/Core/Pathfinding/Path.cs:1126)
Pathfinding.PathReturnQueue:ReturnPaths (bool) (at ./Packages/com.arongranberg.astar/Core/Pathfinding/PathReturnQueue.cs:61)
AstarPath:Update () (at ./Packages/com.arongranberg.astar/Core/AstarPath.cs:865)

[At runtime]

Destroying ABPath instance
Some scripts are not using pooling.
This path was got from the pool or created from here (stacktrace):
  at System.Environment.get_StackTrace () [0x00000] in <1071a2cb0cb3433aae80a793c277a048>:0 
  at Pathfinding.Path.Reset () [0x00000] in <c6b2e15cc19a4f89aaba39cfe5b2f250>:0 
  at Pathfinding.ABPath.Reset () [0x00000] in <c6b2e15cc19a4f89aaba39cfe5b2f250>:0 
  at Pathfinding.Path.Pathfinding.IPathInternals.Reset () [0x00000] in <c6b2e15cc19a4f89aaba39cfe5b2f250>:0 
  at Pathfinding.Pooling.PathPool.GetPath[T] () [0x00000] in <c6b2e15cc19a4f89aaba39cfe5b2f250>:0 
  at Pathfinding.ABPath.Construct (UnityEngine.Vector3 start, UnityEngine.Vector3 end, Pathfinding.OnPathDelegate callback) [0x00000] in <c6b2e15cc19a4f89aaba39cfe5b2f250>:0 
  at Pathfinding.AIBase.SearchPath () [0x00000] in <c6b2e15cc19a4f89aaba39cfe5b2f250>:0 
  at AstarAgentDriver.FixedUpdate () [0x00000] in <0c2922e6081a4d51814caf53e9a2cf67>:0 

These warnings occur whether or not ASTAR_NO_POOLING is enabled.

Mentioned above before I saw your reply - I’m working with AIPaths. I don’t think we have the same issue, as I’m calling the path-search function manually from a separate script. I do also want to stress that everything works perfectly in-editor! It’s only specifically in builds that my agents fail to find paths.

I’ve figured out a workaround, but I don’t know why the workaround works - would appreciate clarity on it!

I keep my AIPath-inheritor component disabled in order to stop it from updating movement automatically (as I prefer to control it via a separate script that governs both navmesh-using agents and others). This previously caused no issues in editor or at runtime. Post-update, it now prevents the AIPath from resolving its path, but only in builds. Obviously this isn’t the intended way to manage an AIPath, and it seems like the RecastMoving issue is completely separate, but this kind of variation between the editor and build behavior is odd and I’d definitely like to know what’s up so I can avoid this kind of issue in the future.

(Also, is it possible to change the topic of the thread? The title is pretty clearly inaccurate at this point).

[EDIT]: …there may or may not be a big “Edit” button next to the thread topic. Whoops.

If you are getting this error, you should probably update your code.
The reason it doesn’t work outside the editor is that this compatibility code is only enabled in the editor, as it has some performance overhead, and is really only intended as a stopgap solution after recently upgrading from 4.x.
Pool debugging shouldn’t have any effect on if this is logged or not.

See the migration guide for more details: Upgrade Guide - A* Pathfinding Project

I’d recommend using ai.canMove=false instead. Or in the latest beta, ai.simulateMovement (same property, but renamed to clarify what it does).
See AIBase - A* Pathfinding Project

If you are getting this error, you should probably update your code.
The reason it doesn’t work outside the editor is that this compatibility code is only enabled in the editor, as it has some performance overhead, and is really only intended as a stopgap solution after recently upgrading from 4.x.

I did check that, but I’m not using StartPath anywhere in my codebase - I’m calling SearchPath and then letting the AIBase / AIPath code handle the process after that. This error also stopped appearing when I allowed the AIPath to update properly. (and yeah, I’ll definitely switch to canMove to reduce the risk of something like this happening again - thanks for clarifying on how that should be handled!)

I went ahead and tried this out for myself and yeah I’m getting the same results (well…on 2022.3.53. I didn’t feel like waiting forever on an install :joy:) Exactly as described, works in Editor but not in build. But then I went and tried the Infinite World example, which also uses AIPath, and it worked fine in both Editor and Build.

If you’re able to post your movement script maybe we’ll see something going on there?