# Stuck zones for NavMeshAgent and Obstacles

I noticed that there are dead-stuck zones near static obstacles, when units getting stuck in situations like shown in the image bellow:

What could be ways to avoid this problem?

You may try to find out when an agent is stuck and move it into another direction for a certain amount of time. When an agent is stuck, you may wait for a certain random duration until it starts to move into another direction and then move into that direction for a certain (random) amount of time, trying to get rid of that situation.

How is easiest way to detect when agent is stuck?

To make the movement as natural as possible, try to imagine what you would do. That naturally leads to the described reaction and you can also find out when the reaction should take place. You are stuck when you have a target that isn’t reached yet, but you barely moved within a certain amount of time.

well, I implemented the way, that it checks current velocity. If velocity is bellow critical threshold, count how many times it appears. If counter hits critical number of counts, assign random temporary target.

The most natural way could be probably to recalculate paths at each point, where is risk of collisions (i.e. adding random delay, or changing one of paths to pass around collision point). This is how in real life it happens - when we see things in the front, we changing our walking direction to avoid colliding with objects. However, to implement such approach would probably need to add avoidance carvings for one agent, while allow to pass the other straight through the point. Do I miss something here?

Usually, it should be possible to rely on Unity’s own obstacle avoidance which already should do this pretty much. Only in very special cases where the agent still get suck, a reaction is needed and in those cases it appears most natural to move backwards in order to free the path for other agents. If you use a random time until this strategy is used, it is very likely that only one agent will use it.