Modify pathfinding cost - DetourNavMeshQuery subclass

Not quite so hard, it turns out. I can’t share much code, but I will give a quick overview:

  • Create a subclass of FRecastQueryFilter, we’ll call it FMyRecastQueryFilter
  • Initialize it’s constructor like
FMyRecastQueryFilter::FMyRecastQueryFilter(bool bIsVirtual) : FRecastQueryFilter(true)
{}
  • override either passVirtualFilter or getVirtualCost (see dtQueryFilter class for details)
  • Create a subclass of UNavigationQueryFilter, we’ll call it UMyNavigationQueryFilter
  • Set bIsMetaFilter = false in constructor
  • override InitializeFilter to look like
Filter.SetFilterType<FMyRecastQueryFilter>();
Super::InitializeFilter(NavData, Querier, Filter);
  • Set this filter (or a blueprint of it) as the filter to use as Default Filter in your AI controller, or use it in the various MoveTo constructs that accept query filters

NOTE: getVirtualCost and passVirtualFilter will be called a LOT. Do not do heavy operations!

4 Likes