How to block territory for NavigationAgent?

Godot Version

4.2.2 stable

Question

In game player can make illusion walls. Enemies consider walls as real, but certain enemy can go through wall if it reveal that wall is illusion.
I use TileMap abd its floor tiles are on navigation layer 1. Enemy’s navagent sees this layer. Problem is navagent way. When illusion wall on floor, floors navigation layer still in the same place as the wall. So navagent of enemy sees floor under wall and make path through wall.
Avoidance doesn’t help. I added picture why.


If player makes a wall in narrow corridor, enemy just hits the wall. Avoidance gives safe vector, but path is still through the wall. On picture 1. - is enemy path in real. 2. - is what I want path to be.
If I could forse navagent ignore territory of wall, It would work, but I don’t realize how

Rebaking the nav-mesh is probably what you want to do

You need to rebake the navigation mesh with that changed geometry because that is what influences the pathfinding.

The avoidance only affects the velocities, so you cant use the avoidance system to change paths, only navigation mesh surfaces changes can.

To anwser you question from the other thread. Navmesh baking performance depends entirely on your source geometry complexity. If your geometry is simple baking will be instant, if it is not, you might as well not even try to do it at runtime.

That is why larger games switch to using a chunk and tile system so they do not need to rebake their entire world on any small navmesh change but just a small section of it. You can do create navmesh chunks with the newer border size added in Godot 4.3, see documentation here Using navigation meshes — Godot Engine (latest) documentation in English

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.