Subclassing NavigationQueryFilter

Big thanks to MieszkoZ for the recent answer, but the struggles continue.

A) Making a functional subclass of UNavigationQueryFilter is weird. I simply use the constructor:

ULavaFilter::ULavaFilter(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
	TSubclassOf<ULavaArea> AreaClass;

But this doesn’t seem to have a functional effect. Do I need to override or call InitializeFilter…?

B) Some methods (NavigationRaycast) use a simple TSubclassOf parameter, but others (ProjectPointToNavigation) use a mysterious FSharedConstNavQueryFilter, which seems like you need to grab from a static method: UNavigationQueryFilter::GetQueryFilter, which has a few overloads. But I can’t get this method to work. I’ve tried

UNavigationQueryFilter::GetQueryFilter(GetWorld()->GetNavigationSystem()->GetMainNavData(), FilterClass)

UNavigationQueryFilter::GetQueryFilter(*GetWorld()->GetNavigationSystem()->GetMainNavData(), FilterClass)

UNavigationQueryFilter::GetQueryFilter<ULavaFilter>(GetWorld()->GetNavigationSystem()->GetMainNavData(), FilterClass)

But it seems to want const ANavigationData&, and I’m not sure how to provide that? How do these things work?


You need to get the value behind the pointer

UNavigationSystem* NavSys = GetWorld()->GetNavigationSystem();
FSharedConstNavQueryFilter Filter = UNavigationQueryFilter::GetQueryFilter(*NavSys->MainNavData, INSERTFILTER);