Can NavMesh detect open and closed doors?

What would be the way to check whether doors are open and closed or not? Is the NavMesh system capable of detecting whether a certain part of the navmesh is changed? I’m aware that it can detect stuff dynamically moving but I was just wondering how good it is. It seems like with detecting objects fallen to the ground and so on that I would need to use invisible colliders and so on to help the Agents figure out what is there and what isn’t.

I’m thinking of very simple stuff, like sliding doors that you see in a lot of management games and so on.

1 Like

The agent by itself does not see anything specific; if it is not in the baked navmesh, the agent use the colliders I believe, to avoid them, but it is not working very well, and it is a waste of resources (at least in my case, it would get stuck).

The navmesh agent has a collider to interact with other agents I believe, while you still need a regular collider for all the other interactions.

You can add dynamically an obstacle component, and set it to carve, so the agent will deal with it more easily. Even if the navmesh is not interrupted, you can place a door and use it as obstacle; when you want the agent to go through the door, you perform the animation to open the door and resume the agent so it will head toward the target.

1 Like

Thanks for that, cleared things up, now that I’m learning more of the basics I’m having a closer look at all the detail of what the engine is capable of.

THe best way to figure out something is to try it; I did notice that the docs in Unity are somehow lacking in many aspects, so you can’t just go through the docs, without give it a try too.

Opening a door is pretty straight forward; there is a tutorial about it on the Unity youtube channel; they also use agents I believe. Take a look at it and see if it is what you are looking for

The example project for navmesh has what you need.
You can also add a navmesh obstacle to your door and toggle on carve.

1 Like

sorry for necroposting but which tutorial are you refferring to?

It is ancient now

There are few more recent that does explain it with more updated version of unity, but fundamentally the gist is the same.

In short; make the door open with a trigger, like you would do in any other example, and when the agent move, it will open the door. The trick is to not make the door part of the wall, otherwise the agent will get stuck. Or you can make the door as “obstacle” and dynamically modify the navmesh, based if the door is locked or can be opened by the agent