- Extend ARecastNavMesh, have its constructor set
bUseVirtualGeometryFilteringAndDirtying = true
and overrideCreateGeneratorInstance
- Extend FRecastNavMeshGenerator, override
ShouldGenerateGeometryForOctreeElement
- Have your custom ShouldGenerate function do checks on the
FNavigationOctreeElement
, it contains the component which is being considered for the navmesh. Can do anything there like check if it’s from a certain actor type or such - Have
CreateGeneratorInstance
return an instance of your custom Nav Mesh Generator class - In project settings under navigation system, set up an agent type which uses your custom recast nav mesh instead of the default one
bUseVirtualGeometryFilteringAndDirtying
needs to be set to true
or the function on the nav mesh generator won’t be called.
The default ShouldGenerateGeometryForOctreeElement
uses Element.ShouldUseGeometry(NavDataConfig)
, but calling Super
would probably work.
To pull component/actor out of the FNavigationOctreeElement
:
//This is (probably always?) a UPrimitiveComponent
UObject* Owner = Element.Data->GetOwner();
//since it's a primitive comp you can get the actor...
AActor* OwnerActor = Cast<AActor>(Owner->GetOuter());