Can I create volumes on the fly programattically?

Is it possible to create volumes on the fly? I’d want to create new navigation volumes for example at run time as new parts of the level get added.

Bumping this up to see if anyone has any answers.

I’m starting to wonder if this is possible at all since volumes appear to be baked from the brushes created in the editor. It looks like a UModel is ultimately created from that.

I too was wondering this, i couldnt find anything outside the editor for adding navigational volumes.

As volumes use BSP and BSP cannot be recomputed at runtime, the short answer is no.

The long answer is internally, nav volumes in particular don’t really require to be BSP, it just happens that BSP brushes provide an easy editor-driven way to define volumes. The actual struct doing the work is FAreaNavModifier, and it can accept a cylinder shape, a box shape or an arbitrary convex shape. Add the INavRelevantInterface interface to whatever actor you want to modify nav volumes with, then in your implementation of INavRelevantInterface ::GetNavigationData, you can create your own FAreaNavModifier and work from there.


Would I be able to spawn multiple such shapes for the different rooms and have it act as one giant volume?

At the moment, I have a giant empty level with a giant nav volume. I have working nav mesh creation, but it ends up creating navmesh geometry on outsides of the level too. Like if I have a room with static meshes making up the roof, I have nav mesh geometry up top in the roof itself. Ideally I’d want it to be only on the floors.

I’m not sure how this works internally but it seems like I’m making the engine do a lot of pointless extra work, and it would really help clean it up if I can let it generate better nav mesh data with better volumes that only encompass the walkable areas.

FNavigationRelevantData.Modifiers is a composite of multiple modifiers, so yeah, you could have multiple volumes.

I can’t speak for everyone, but we don’t bother excluding unreachable surfaces from the navmesh. AIs won’t try to path there anyway, unless you request a random navmesh point that ends up there. Instead, we always filter our navmesh point requests to whatever surface type we want and those areas are valid.