When a navmesh modifier enters the navmesh does it automatically regenerate?
Hi Unreal Inmates,
This is a common bug on many forums, but I figured I’d post it, that way our collaborative brains can solve it… or I can post an answer when I eventually do.
So, here’s the scenario:
- Big open world with root persistent level.
- Streaming levels hold navigation volumes.
- AI actor is in the persistent level.
- Navigation data is generated at run time (CLI “show Navigation” shows the awesomeness.)
- A dynamic “Recast Nav Mesh” actor is created at runtime and visible from the World Outliner.
- 1 or more Navigation Data objects are generate. (examined "get all classes by type and checked array length)
- Manually checking each one in the AI Blueprint and handing the results into “GetRandomReachablePointInRadius” produces a positive result, suggesting one of the Navigation Data objects holds the “green nav mesh” in the included photo.
- When “move to” called, the AI doesn’t move and the movement is canceled.
POI: This setup originally worked great for about two weeks. It also is reminiscent of this issue, who had success by moving his assets to an entirely new level.
Expected: “Move To” should have access to all the compressed Navigation Data and should move the pawn to the elected location in the green nav mesh.
Hypothesis: “Move To” some how gets disconnected from access all the Navigation Data (such as the dynamically created “Recast Nav Mesh” actor), and, though the data is there in the Navigation Data objects, the Move To can’t see it.
MORE INFORMATION:
Toggling the AI Debug Mode in the PIE editor – Press the ’ (apostrophe) key – actually shows me that there is no NavData being loaded into the AI (which supports the Hypothesis).
See the 5th line up from “Montage: None” on the right-hand side of the screen, it says “Nav Data: , Path following: Idle” which, from official documentation:
AI Debugging | Unreal Engine Documentation,
That shows us there should be something there… e.g., “default.”
I ran this on the ALS v4 demo and a couple other working demo projects, and it confirmed there needs to be NavData for the AI to know what to do. (Yes, I know sounds rudimentary). Additionally, I spawned a navigation mesh volume in my persistent and added a base AI class and actor to it, but with no success, the NavData no longer showing up in my AI Debug readout.
Augmenting my Hypothesis: Somehow the NavData is not being loaded into the AI system as an option to use. Ye, we can see it, yes, it’s there, but without a declared class or reference, the AI system can’t apply it to the AI actors. More to follow as I run scenarios through my mind.
If you guys have any thoughts, let me know, and if not, I’ll try and figure this out and post an answer ASAP.
Yes, I have multiple modifiers and objects that move across the mesh and they cause the mesh to regen (turn red, and then restructure). The key with this one, as with many others, is it seems to have arisen following a period of time when it worked as expected. As the dynamic nav mesh count grew, inconsistencies started happening, and now it doesn’t work at all.
This answer is short and sweet. If you end up not having any NavData in your AI debugging widget, can see the dynamically generated navigation mesh and your AI isn’t paying attention to it, you may need to tell the Unreal engine to actually use the runtime generated navigation mesh (dynamic “Recast Nav Mesh” actor), as default.
This is done in the Project Settings, under Navigation Mesh, ensure “Can be Main Nav Data” is checked. If it isn’t, Unreal will disregard your recastNavMesh.
This is a post I found, with the exact answer, just moments after I found it myself through using the AI debugger:
This may be an actual engine bug with 4.26, but I’ve had the “Can be Main Nav Data” checkbox untick itself several times in the last 24 hours. Keep an eye on the checkbox and your AIs should still work.