Update navmesh when door opens

I have a level with multiple doors that will dynamically lock or unlock during gameplay. They could plausibly lock either open or closed. So, I would like to update my navmesh dynamically, so when the door is open characters can walk through, but they don’t try to walk through it when it is closed.

So far, I have a simple sliding door that moves when any object approaches, and I turned on “Rebuild at Runtime” and “Build Navigation at Runtime.” However, my navmesh doesn’t change when the door slides open or shut.

a) How can I make the navmesh correctly update when the door slides?
b) Is this the proper technique to achieve what I’m trying to do? Or should I be using something else, like nav-links that I add/delete as needed?

Hi natemartinsf,

You said that you had Build and Rebuild Nav at Runtime on. Did you also do this in the RecastNaveMesh asset?

Just checked, and “Rebuild at Runtime” is checked on the RecastNavMesh asset.

While playing your level, hit the ~ key and pull up the Console Command. Enter ‘Show Bounds’ without the brackets. All collision should show as blue boxes. Is any sort of collision present in the doorway when the door are set to open?

Sorry about the slow replies, I unfortunately have limited time to look into this.

See my comment above, I’m still running into this issue,

I’ll post some screenshots when I get home, but yes there is a collision box on the door frame as expected, but just on the frame itself, not the gap between. (The door frame is the model included with the sample content)

Hi natemartinsf,

I created a set up with the default door from the starter content. The default size is almost a 1:1 scale of a standard real-life door, which is actually a little small for an in-game door (generally things are scaled up a bit). However, I was able to get the navmesh working correctly with the door at it’s default size by adjusting the RecastNavMesh settings.

  • Change the Cell Size and the Agent Radius both to 1.

  • When in-game, open the door and allow a few seconds for the navmesh to recalculate.

  • The path looks narrow but as long as it’s connected an AI will be able to walk through the door as long as the AI’s capsule is correctly sized.

Let me know if this works for you or not.

Cheers,

TJ

I just tried this, but once I’ve changed those settings, the game locks up. If I click the “play” button, it starts, then hangs, accepting no input. I have to end the task.

To make sure that the hang isn’t something to do with my project, I made a new project, just made the changes you mentioned above, added my sliding door, and turned on rebuilding nav at runtime. Still hangs.

That is odd. Could you upload your dxdiag? If your on Windows just search under the Start menu for 'dxdiag/ > Save All Information > then upload the test file.

Does the freezing occur with slightly larger values in those variables? If so, would your project allow for the doors to be a little larger?

link text
I’ve attached the dxdiag file.

It seems that the smaller I make the two variables, the more the frame rate drops. Setting them both to 15 starts to make it noticeably slower, setting them both to 8 is about 2 frames/second.

I’m sorry it’s been a few days. Your system specs are similar to what I am using here so that shouldn’t he an issue. Could you try recreating the navmesh where it causes the framerate drop but in a new project without starter content? If you can, please post a link here for me to download and test in-house.

What is causing this issue is the ‘Execute Console Command’ being called on Tick. If you disconnect this it will no longer have framerate issues.

As long as ‘Rebuild at Runtime’ is enabled, this command shouldn’t be necessary.