How to disable Nav Modifier Component

Hi All,

I’ve been able to successfully use NavAreas, QueryFilters and the Nav Modifier Component to be able to modify the navigation of certain agents.

This is achieved by several actors in the world having a Nav Modifier Component with a Nav Area set and then using a QueryFilter with the AI MoveTo.

But, sometimes I want these actors to not have this modifier. I want the ability to turn these modifiers on or off. I can see no way to do that. I’ve tried to set Navigation Relevancy to false but this doesn’t seem to work. I’ce also tried exposing the AreaClass on the component to the blueprint and setting that to a different NavArea but that also doesn’t work.

How is this achieved?


Set the ‘Area Class’ to ‘NavArea_Null’.

Then, when you want it back on, set it to the class you used previously. You may wish to save that to some variable to restore previous state easily if there are more than 1 possibilities.

Thanks for the response.

Forgive me but if you set it to NavArea_Null then shouldn’t that mean the area can’t be traversed at all? Did you mean set the Area Class to “None”? That is what I thought should do the trick, but it doesn’t seem to have any effect. When setting the NavArea to “none” or “Nav Area Default” the agent is still avoiding the area.

I wrote a longer comment but it got lost after clicking post… Ehh…

Yes it’s None and not Null (why is this different I don’t know).

That’s not the whole story though. If you wanna change it run-time, you need to tell it to the project. By default all paths are static, which means that once editor calculates them, they never change.

Project Settings → Navigation Mesh → Runtime Generation. Go with Dynamic Modifiers Only (thats what you’re asking for, unless you want moving objects with collision to update paths as well).

It will register the change up to tick interval later (default 0.5) then recalc the navmesh on the affected node(s). The bigger and more complex the node the tougher the calculation so choose your recast parameters well and do not overuse that feature (if you care for performance that is).

Ahhh! Thank you for that titbit of information. That was part of what I was missing. I had not set runtime generation to Dynamic Modifiers Only.

Although, that wasn’t the complete solution. It still wasn’t updating. I had to expose and manually call RefreshNavigationModifiers myself. Not sure if that’s the wisest thing to do as that means it is doing it then and there and not when the system decides to do it.

It is at these times I wish UE4 had more documentation of it’s features.

This required several changes. Thanks to vipeout for the help.

This setting needs to be set.
Project Settings → Navigation Mesh → Runtime Generation → Dynamic Modifiers Only

I was doing this in blueprint so in NavModifierComponent I also had to expose AreaClass as BlueprintReadWrite.

Then in the parent class NavRelevantComponent I had to expose RefreshNavigationModifiers as BlueprintCallable.

Then when I want to switch the Nav Modifier on the actor off I can set the AreaClass to either “none” or “default” and then call RefreshNavigationModifier. I’ve had word from Epic staff that this is OK to call.