So I am noticing with a dynamic navmesh and world composition. My navmesh is generated in editor but when I hit play it’s just gone and never generated again. My AI just stand around without a path.I hit P and am showing navigation in editor. I see the green navmesh, hit simulate, navmesh is gone. In a non-world composition map or non-dynamic navmesh it seems to work but specifically mixing dynamic navmeshes and world composition seem to give me problems directly.
What I’ve tried
Putting my nav mesh bounds in my persistent level, no change but I switch to static navmesh this of course works but I really need a dynamic navmesh with world composition.
I’ve dug into the AI Moveto command and it shows me that it simply can’t find a point in the navmesh within range. I am making a space game so I checked and 100% made sure the point was on a physical piece of mesh or really close to it. It is, checked in editor. Very specifically from my dig FPImplRecastNavMesh::ProjectPointToNavMesh Where it does Find nearest poly 2d and then the PolyRef is 0, around line 1370 in 4.18 codebase.
Additionally dynamic navmesh works if I load one of the pieces directly thus not using world composition, it works but then I am missing world composition.
Turned off “enable world origin shifting” although I am not using this yet directly in code. I believe you have to call something specifically to shift your origin, is this right? Either way, on or off the same results on dynamic navmesh with world composition.
So is it possible to use dynamic navmeshes with world composition? If so any ideas on where I horribly went wrong? I feel like there is a checkbox I am missing to generate this dynamic navmesh within world composition.
I did a bit of testing and was able to get the dynamic nav mesh working with world composition by doing the following:
Enable World Composition in the persistent level’s settings
Cover the playable area with a NavMeshBoundsVolume
Go to Project Settings → Navigation Mesh and set Runtime Generation to Dynamic
Go to landscape settings and set Used for Navigation to true (probably not applicable to you since you’re doing a space game, but it wouldn’t hurt to mention)
To test this, I placed several of the default Cube static mesh in the scene, scaled them up large enough to accommodate a nav mesh when generating in-editor, set Simulate Physics to true, and set mass to 100 so I could easily move them. Then I went in-game (in both Play in Editor and Standalone), turned on nav mesh drawing with the command “show Navigation”, and started pushing the meshes around to confirm the nav mesh was updating.
A few more quick troubleshooting tips from what I’ve noticed:
Nav meshes need a fairly large area to generate on. For example, the default engine Cube in the side panel is not large enough to have a nav mesh generate on top of it without being scaled.
Nav meshes have a limited angle at which they generate. This can be changed in Project Settings → Navigation Mesh.
I have noticed navigation meshes seem to be designed more for ground-based NPCs since they generate in a planar fashion, so if you have free flight in space this system might not work for you. I could be wrong on this though, it’s just an observation from my brief foray into setting up a nav mesh recently.
Hopefully this info can help you figure out what’s wrong with your setup!
Did you try with world composition enabled? in your steps you enable the dynamic navmesh but not world composition in the world settings, additionally for my setup you would have to have the levels not be the persistent level but instead a sub level.
The navmesh successfully generates when static is selected. So I don’t believe it’s an issue with angle or size. This is while you are in a space station so while a space game just means there were parts of the world where a point might reasonably not have a navmesh 2D near it or a walkable surface. In this case they do and they work at the same points just with static instead of dynamic.
Sorry, I did have world composition enabled, I just didn’t explicitly mention enabling it since I said I got it working with world composition. I’ll edit the post to fix that inconsistency.
I have two landscape sub levels that are streamed in by world composition and they both are generating nav meshes with the settings from my main post. As long as the sub levels contain NavMeshBoundsVolumes, they should generate when streamed in with dynamic generation. Maybe check the Navigation System section of project settings to see if Auto Create Navigation Data is set to true, Data Gathering Mode is set to Instant, and Generate Navigation Only Around Navigation Invokers is false. Those should be the default values since I haven’t touched them at all on this project, but I figure it wouldn’t hurt to check.
Other than that, I’m not sure why your dynamic runtime generation isn’t working, unless there’s some option in your project settings that you’ve changed that differs from the defaults.
I rebuilt my test in a small project so you can see my setup firsthand and compare it with yours. All you should have to do is open the level Maps/TestPersistent (should be loaded by default though), hit play, enter the console command “show Navigation” and then run toward the two cubes at the edge of the landscape in front of you until world comp streams in the map TestB. You should be able to watch it generate the nav mesh once the level is streamed in, and the large rectangle mesh can be pushed around to further confirm it is updating. Here’s the project
Diving into it I also made a project from scratch real quick in the same style and came up with the same results. Puzzled I opened project settings for both projects and through line by line considerations found that the box “Initial Building Locked” was checked and I never called release.
Oddly enough this seems ignored on non-world composition maps and non dynamic nav meshes.
Thanks for your help. Sitting down with the settings really helped. I knew it was a silly checkbox somewhere.