# Modify pathfinding cost - DetourNavMeshQuery subclass

**URL:** <https://forums.unrealengine.com/t/modify-pathfinding-cost-detournavmeshquery-subclass/342472>\
**Category:** World Creation\
**Tags:** pathfinding, Navigation, unreal-engine, navmesh, question\
**Created:** [December 26, 2015, 8:04pm UTC](https://forums.unrealengine.com/t/modify-pathfinding-cost-detournavmeshquery-subclass/342472 "2015-12-26T20:04:29Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![eblade](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eblade](https://forums.unrealengine.com/u/eblade)\
**Post date:** [June 2, 2022, 7:16pm UTC](https://forums.unrealengine.com/t/modify-pathfinding-cost-detournavmeshquery-subclass/342472/13 "2022-06-02T19:16:04Z")

</div>

> [@MilkyEngineer](#):
>
> Solution 3: Extending dtQueryFilter (Hard)

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

```auto
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

```auto
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!

---

_[View the full topic](https://forums.unrealengine.com/t/modify-pathfinding-cost-detournavmeshquery-subclass/342472)._
