Forum rules - please read before posting.

Change navmesh at runtime?

I'm using Unity's navmesh in a 3d game, and I have a closed door which is 'non-walkable', but once the door is opened, I want the player to be able to go through it. Is there a way to change the navmesh at runtime, or is there a better way to achieve this? Going through the door will trigger a scene switch, so it could be part of a cut scene if that makes it easier.


  • Unity's built-in NavMesh system can't be re-baked at runtime.

    In a case like this, you're probably best off having the NavMesh span both rooms, but then preventing the Player from being able to move into the other while the door is closed.

    If you're using point-and-click movement, this can be done by placing a collider on the "Default" layer that spans the dividing wall, so that clicks on it will not "pass through" to the other side.

    If the other room is a different scene, and you just want to have the Player move through the doorway before switching, you could alternatively leave the NavMesh baked to just the "main" room, and then just move the Player without pathfinding. This can be done by unchecking Pathfind? in the Character: Move to point Action.

    As an alternative to Unity's NavMesh, AC's "Mesh Collider" pathfinding option - which relies on a pre-authored mesh to describe the walkable area - does support changing at runtime.

  • Thanks, that Pathfind option was exactly what I needed!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.