I’m working on an AI-driven NPC system in Unreal Engine 5, and I’m currently facing some challenges with pathfinding when it comes to dynamic obstacles in the environment. I’m using the default NavMesh system with AI Controllers and Behavior Trees.
Here’s what’s going on:
The AI agents navigate just fine around static meshes and predefined obstacles.
However, when I spawn dynamic actors (like physics-based debris, moving platforms, or destructible objects), the AI either gets stuck, doesn’t update its path, or tries to walk through the object as if it doesn’t exist.
I’ve tried calling RebuildNavigation() and FlushPersistentDebugLines() via blueprint and C++, but it seems either too slow or inconsistent.
A few more notes:
I’ve set the dynamic objects to be “Dynamic Obstacle” in the collision settings and ensured they are registered with the NavMesh.
I also enabled Can Ever Affect Navigation on the actors and components.
The NavMesh is set to “Dynamic” and I confirmed that Runtime Generation is set to “Dynamic” in the project’s Navigation System settings.
What I’d like to ask is:
Is there a more efficient or optimized way to handle AI navigation updates when dealing with dynamically spawned or moving obstacles?
Is it a good idea to use “NavModifierVolume” or “NavLinkProxy” in these scenarios?
Or would I be better off using Environment Query Systems (EQS) or some custom pathfinding logic?
Any insights or tips — especially if you’ve tackled similar problems in your own projects — would be incredibly appreciated. Thanks a lot for reading and for any help you can offer!
Well to be honest I am still running some experiments on my game aswell. I am using couple of different techniques and approaches.
When AI moving but velocity of pawn gets close to zero for more than X miliseconds, try recalculate path.
If AI is stuck or have an obstacle, I have a jump ability for acting differently (modifyable) that detect if the object infront is jumpable. Like if some physics objects close path they try to get through. It is also for now working with unreachable zone where there is no NavLink exist.
For some I am planning to add a somewhat physics interaction condition: like a put a rocket on the blocking object or if its melee add force (punch) to move through.
Similarly you can run a task to detect if an obstacle on path create a half circle EQS to avoid things. I think it will even appear smart in some situations if AI does that, like predict the physics path of the dynamic object.
However I am open to ideas to make them smarter in these situations aswell, would like to hear other devs opinions aswell.
I had the same problem not too long ago, here’s the ways that I tried:
“Dynamic navmesh + nav Invoker” to rebuild Navmesh only around the player but I still had performance issues.
For AI to AI avoidance I tried “Detour Crowd” and “RVO” but the results I got were not smooth enough and I found the options limited.
I ended up creating a custom solution that I included in my plugin on Fab called “Enhanced AI Movement” (showcase | fab link) The algorithm is based on simulated sensors (result in the showcase video after 1 min 03). It uses the default path finding but the trajectories are modified based on the sensor results to avoid dynamic obstacles.