- Home /
Navemeshagent and doors
I'm trying to make an agent that patrols around a maze (the maze is proceduraly generated, it's many rooms connected with doors) the problem is when the agent reaches a door, i wrote a script where if the agent gets near a door the door opens but that doesnt give goood results because the doors are walkable so the navmesh doesnt consider them an obstacle wish makes the agent stuck if the door opens and gets in it's way. I've been looking everywhere on the internet but no one solutions found. If anyone has an idea or a way to make this work i'll be very thankful.
Answer by TanselAltinel · May 09, 2018 at 02:44 PM
Use NavMeshObstacle on doors: https://docs.unity3d.com/Manual/class-NavMeshObstacle.html
Disable carving for doors. When the door is opened, disable obstacle and enemy will continue.
This is considering Enemy AI has no other possible option to continue the the goal.
I added Nav$$anonymous$$eshObstacle to doors and set the obstacle avoidence radius to 1 and it works great but there is one issue that still rises if the agent opens the door and the door opens on him he doesnt try and go around it ins$$anonymous$$d he tries to go throught it to follow his path and therefor he's stuck :/
Well in that case do not disable obstacle.
Yes i didnt do that but it still behaves that way i dont understand why.