0
\$\begingroup\$

I'm trying to make an agent patrol around a maze. The maze is proceduraly generated and consists of many rooms connected with doors. The problem occurs when the agent reaches a door. I wrote a script where if the agent gets near a door, the door opens, but the results are bad because the doors are walkable, so the navmesh doesn't consider them as obstacles and the agent gets stuck if the door opens and gets in its way.

I've been looking everywhere on the internet, but haven't found a solution. If anyone has an idea or a way to make this work, I'll be very thankful.

\$\endgroup\$
  • \$\begingroup\$ Why are the doors walkable? \$\endgroup\$ – TomTsagk Sep 20 '18 at 14:00
1
\$\begingroup\$

I think what you're looking for is the NavMeshObstacle component.

https://docs.unity3d.com/Manual/class-NavMeshObstacle.html

https://docs.unity3d.com/ScriptReference/AI.NavMeshObstacle.html

\$\endgroup\$
  • \$\begingroup\$ This seems to be the correct answer, however for future readers I think it would improve if in addition to providing links, you could also describe why NavMeshObstacle is the right answer, and maybe a small example of how can someone use it. \$\endgroup\$ – TomTsagk Sep 20 '18 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.