- Home /
Navigating to Closest Point on NavMeshObstacle
I have a carving NavMeshObstacle acting as a door to block passage through a wall:
If an agent is outside the wall - in this case to the right - and targets this block to come and attack it, we want it to navigate toward the obstacle. The transform.position
of the latter is inside the complex, which causes the agent to find some alternate route all the way around the wall.
My tentative buggy solution is to derive the closest spot on the edge of the obstacle in a straight line to the agent, and navigate there. That only works if the agent is in direct line of sight; if not, there are times when it is best to navigate around the wall as it's now doing.
What would be most handy is if you could set a NavMeshObstacle's block-out area to be a certain walkability area at runtime, a feature I have yet to find.
Any other ideas?
Your answer
![](https://koobas.hobune.stream/wayback/20220612105317im_/https://answers.unity.com/themes/thub/images/avi.jpg)