Pathfinding works in editor, not in standalone build

Hello,
I noticed the problem I’m having is very similar to this issue Graph does not work in build - General / Recast graph - Support Forum (arongranberg.com). Everything works as intended when running in the editor, but when running in the player the AI’s are unable to get a path. Just like in the linked topic, there are no errors occurring. In the editor, scanning the mesh at runtime takes about 40ms, while standalone takes 90-100ms.

In your answer, you said:

"Typically, this can happen if

  1. The meshes are not readable at runtime. This shouldn’t be an issue for you, though, since you are using collider meshes, and they are usually readable.
  2. Your objects end up in the wrong layers in the build.
  3. Your objects are loaded asynchronously, and they aren’t actually loaded at the time when the scan happens."

Hopefully this is enough info about my situation:

  1. The colliders being used are one terrain collider, five Umodeler mesh colliders (mentioning because I saw in a different topic that probuilder makes meshes difficult for the pathfinding to work with), and all others are character controllers.

  2. I will admit, I know less about how layers (and unity) work than I would like. The gameObjects using pathfinding are all part of the “Troop” layer. Players are “Player”. The walkable area is on the “Ground” layer. Could these custom layers be messing things up?

  3. While probably not the best solution, my troops set their destination every frame by checking their RichAI.hasPath field, and using AIDestinationSetter in Update().

In the logs, it is clear that scan() happens. But, even with the “cache on startup” option selected in the pathfinder component, it seems like the RichAI’s are not able to create a path.

I can supply video of the problem and logs if necessary. Thank you!

Hi

I’d double-check the logs for any related messages. In 99% of the cases, there will be a log message about some meshes not being included in the scan.

What error message does pathfinding log when it cannot calculate a path?

Solved! it was my code not yours, sorry.

1 Like