Navigation mesh for NPC's is slow to calculate or doesn't calculate at all

Summary

I’m working on a game with Moba elements and thus with NPC’s that follow certain paths from one base to another.
I noticed my guards not always following the paths after they spawned, so I looked at the navigation meshes. When inspecting them, I learned that they calculate very slowly, and sometimes, certain areas don’t calculate a nav mesh at all. When I end the game and play again, without making any changes, these areas suddenly get nav meshes correctly.

I don’t find any documentation on what could impact the speed of nav mesh calculation. I don’t feel like the map itself is abnormally large at all.

I’m using the NPC spawner that triggers after 2m30s in the game. But I would expect that as I’m running around as a player, the nav meshes should already calculate, which is not the case.

Are there specific limitations I should consider?
Can I optimize it somehow?
On a long route, is it better to use more or less patrol path nodes? Does this have an impact or not at all?

The map contains six groups of patrol nodes. Four small circles and two long paths between both bases.

Please select what you are reporting on:

Unreal Editor for Fortnite

What Type of Bug are you experiencing?

AI

Steps to Reproduce

  • Created map
  • Added patrol path nodes and NPC Spawners
  • Sometimes Nav Mesh is not generated or very slowly

Expected Result

Almost immediate result for navmesh so that the guards don’t stand still in place after spawning.

Observed Result

Slow or no navmesh calculation

Platform(s)

PC

Upload an image


I did find this documentation page from Unreal Engine Optimizing Navigation Mesh Generation Speed in Unreal Engine | Unreal Engine 5.5 Documentation | Epic Developer Community

But I don’t find options to resize nav mesh cell sizes in UEFN or the “Can affect Navigation” option on Fortnite assets.

I’ll try to get someone to take a look.

1 Like

To add on the thread:

Currently streaming is enabled, but I also did a test with streaming disabled which had the same result.

In the NPC Character Definition I have “Always Generate Navigation” enabled in the Navigation Mesh override. However I would expect that as a player I also trigger navigation area in a radius around me.

Hello @mapshot-stece,

In the first screenshot you shared, the patrol path is malfunctional due to there’s valid navmesh (with these red cross sign and red lines), the second screenshot shows the navmesh is generated and patrol path is functional properly.

For the navmesh generation, once we have an NPC Spawner (or any other AI Spawners) in the island it’ll try to generate the navmesh, since you have already got an NPC Spawner placed then the navmesh should always be generated.

When inspecting them, I learned that they calculate very slowly, and sometimes, certain areas don’t calculate a nav mesh at all.
When I end the game and play again, without making any changes, these areas suddenly get nav meshes correctly

Regarding the situation you’ve hit above might be introduced by two reasons:

  • The navmesh has been generated but taken too much time to get replicated to the game client, so the navmesh debug view has a delay to show the correct result.
  • The navmesh has a slow generation in this specific area, this would likely be happen if the area is dynamically loaded / unloaded.

Could you share a bit more of your setup in this area? It’ll be very helpful to learn:

  1. What are those props used in this area, are they all Fortnite props or you have custom imported props as well?
  2. Is there anything changing this area dynamically? Like loading or unloading assets during the game?
  3. How far is the area away from the closest NPC Spawner?
  • The navmesh has been generated but taken too much time to get replicated to the game client, so the navmesh debug view has a delay to show the correct result.

=> This is not the case because if it were an issue of visualizing the debug mesh, the NPCs would still behave normally, which is not the case. I would also expect that in that case, the Patrol Path wouldn’t be red with crosses as it should be valid/working in the case it was generated, but the debug visualization is delayed towards the client.

(Standing still NPC’s at their spawner, no nav mesh being generated)

  • The navmesh has a slow generation in this specific area, this would likely be happen if the area is dynamically loaded / unloaded.

I’m not using any dynamic loading in this area with a datalayer, cinematic or Verse.

  1. What are those props used in this area, are they all Fortnite props or you have custom imported props as well?

In this area I’m only using Fortnite props. I do have custom props in the game, but they are not placed in this area on the ground. Some are on the walls (banners), but the walls themselves are Fortnite assets.

How far is the area away from the closest NPC Spawner?

Not sure how to measure or explain this. But it isn’t far at all. I’ve attached a screenshot.
On the left with a red circle, I have two NPC spawners. These are configured to follow the blue line patrol path group with 1 and 2 being the first nodes. Which are the nodes on the screenshot of my initial post. There is a third NPC Spawner, which is linked to the orange lines patrol path group. This NPC spawner is encircled in Blue.
Imo it’s not an issue from distance between NPC spawner and the patrol path nodes.

(I’ve also done a test where I moved away the secondary PAtrol Paths with the orange lines to see if intersecting paths were causing an issue. But this was not the case.

I also have an issue where the NPC’s take a large unneeded detour. If the nav mesh was generated correctly.


On this screenshot you can see the patrol path suddenly going to the back instead of going forward. Eventhough the nav mesh is entirely green. There are no obstacles on the ground.


This is a screenshot from the same area in UEFN. You can see a faint blue and yellow line just following the path forward. It’s on terrain. These are two patrol path groups, one for an attacking army in one castle to the other, and one for an army in the other direction.

And even though the navmesh is completely green as seen on the first screenshot, and the patrol path is just following the straight line forward, they take a detour through the forest. :sweat_smile:


In blue circles the nodes of the patrol groups and red the lines the NPC’s actually follow.


No obstacles on the path they should take between the two nodes, which is the shortest path going forward.

Clicked ‘End Game’ and then ‘Play Again’ without changes and now the path just goes straight.

Thanks again for all the details, it’s super helpful and what you’ve done here looks all correct and should have navmesh generated, the patrol path detour is also a very weird issue and I agreed it should be using the straight line in your setup.

I’m getting back with the information to the engineer and we will let you know once we have any further updates.

1 Like

I was doing more tests, and I’ve seen play sessions in which the patrol path is visualized straight and other play sessions with the detour. I did notice that when the detour was visualized, the NPCs still walked forward sometimes. So that might be just a debug visualization issue after all in some cases.

However, I do still see issues in parts of the map getting no navmesh in one session and a working navmesh in another. But I can’t put my finger on the root cause.

I did add a couple more Patrol Path Nodes, so it’s broken in pieces a bit more, which does feel a bit more stable, but not 100% yet. But there are also issues where the Patrol Path Nodes are relatively close to each other, sometimes breaking and sometimes not breaking. As in the earlier screenshots I shared.

@mapshot-stece could you DM me your project so we can investigate further?

I have some more information @Flak @QH_DreamMaker

I was still thinking about the earlier question from @QH_DreamMaker regarding the dynamic loading of assets.

I have some cinematic devices with icons constantly going up and down. These are meant to help guide the players in what they are supposed to do.

When I deleted the cinematic devices, I noticed the navigation mesh fully generated correctly a few times in a row.
So I assume those meshes going up and down constantly in a loop, is causing the engine to constantly try to regenerate the navigation mesh. I didn’t make the connection earlier since those icons are nowhere near the location of where the patrol paths broke. But I assume every movement cycle of those icons triggers a regen of the nav mesh.

I removed collision on those icon meshes in the hope that it wouldn’t impact regenerating the navigation mesh anymore. But that doesn’t seem to be the case. Is there a way so that those cinematics don’t impact the navigation anymore?


FOUND IT! :smiley:

Thanks for asking the right questions, I would never have made the connection between the Nav Mesh and those icons going up and down!

Cool, thanks for figuring out the problems and yeah the Can Ever Affect Navigation is the flag you need to use to determine if the navmesh would be affected by the props or not, even if it’s only a 3D icon in the world.

When there’s a moving object in the world, it’ll try to have the navmesh calculated to try to regenerate the proper navmesh to avoid NPCs being blocked by the object, so you are right in your case you’ll see the navmesh keep being updated.

Additionally, once you perform the fix, is the Patrol Path working properly now and your NPCs are following the right path that you’ve designed?

I havn’t been able to replicate the detour issue since. My assumption is because the nav mesh generation was being delayed, there was a section that initially had no navmesh when the Patrol Paths formed their lines, so it went around that section. Sometimes, it than generated correctly afterwards, making the random behaviour of NPCs sometimes going straight and sometimes going via a detour.

1 Like

To add some details here for future users reading this:

At the time of writing this, UEFN uses Nav Invoker to generate navmesh instead of generating the whole navmesh of the experience as in regular Creative.

Each patrol path device will generate navmesh around itself with a radius of 100 meters. Make sure to place the next point within that radius.

Navmesh will also be generated around at these radius for:

Player/NPC/Camera = 50m radius
Creature Placer = 5m radius
Creature Spawner = 40m radius
Wildlife Spawner = 60m radius
Guard Spawner = 60m radius
NPC Spawner = 60m radius

1 Like