Search Unity

Resolved NavMeshAgent & Doors

Discussion in 'Navigation' started by Error-102, Feb 19, 2023.

  1. Error-102

    Error-102

    Joined:
    Jan 20, 2021
    Posts:
    9
    Hello everyone,

    Maybe you stumbled upon this post looking for answers or are just curious, but a few of us may have found that NavMeshAgents and Doors do not mix well. If you make the door 'Not Walkable' and bake it, then when the door is closed, everything works fine, but if it's open, the NavMeshAgent can't walk through. If the door is walkable, and open then everything is fine as well, but if it's closed the Agent with continue to try to walk through the door. So, what do you do about this?

    Well, I figured out a simple (yet hard to find) solution.

    1. Select your door

    2. Add the 'NavMeshObstacle' component to it
    - Make sure to adjust the size and all

    3. Turn on the 'Carve' option.
    - This will literally carve out space for the NavMeshAgent to walk.

    If your door is open enough, the space will be walkable.
    If your door is closed, it won't be walkable.

    This work for both hinged doors, trapdoors, slide doors, and more!

    I hope I helped someone. Thanks for reading and enjoy your new door!

    Peace,
    Error 102
     
  2. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    Just keep in mind that only works if you want your agents to not be able to open doors!