Odd unit behavior when surrounding a target object

Environment:

  • A version:* 5.4.5

  • Unity version: 6.3

Description: I am trying to implement a behavior where units surround a target object, but some units are exhibiting very strange movement. Even when a unit is very close to its destination and the path is clear of obstacles, it occasionally decides to pull a U-turn, taking a long detour only to end up back where it started.

This movement looks very unnatural. Is this a known bug, or am I missing some specific configuration parameters?

English is not my native language, so I hope I have explained the issue clearly. Any insights would be appreciated!

This is the screen recording of the behavior:

This is the screenshot of my configurations:

Can you share the code for the circling?

Sure, here is the code. There isn’t anything particularly complex in the logic; it’s a simple State Machine with two states: Approaching and Attacking.

  • Approach State: The unit searches for an available spot around the target (the green circles in the video) and sets the nearest available position as its navigation destination (indicated by the green line).
  • Attack State: Once the unit reaches an optimal attacking position, it locks its movement (the units with red dot in video).

You may want to turn off RVO when they are close enough to the spot. Local avoidance, by way of taking into account strictly local information, has a tendency to doing things like this- specifically, by default it has a right-side passing bias. It may look unnatural to “go through” other units for a split second, but functions a lot better than going the complete opposite direction.

Thanks for the suggestion!
I actually tried disabling RVO when units get close to their destination during my own testing, but it introduced two issues:

  1. Overlapping: When multiple units are near the target, they end up overlapping/stacking on top of each other once they stop.
  2. Timing: The “U-turn” behavior happens at unpredictable moments, making it difficult to determine the exact timing to disable RVO.

Additionally, I have a few more questions:

  1. Why does the right-side bias cause a U-turn even when there are no other units directly in front of it?
  2. Is there a way to make local avoidance only consider units in front of the agent and ignore those behind it?

I’d love to hear your thoughts on these. Thanks!

I encountered another issue during testing today. When I placed a static obstacle next to the target object, the units started crowding into a single corner.

Even more strange—some units would attempt to move toward an available empty spot, but after taking just a few steps, they would immediately pull a U-turn and head back. This behavior feels very strange.

They end up overlapping/stacking after they’ve reached their “spot” around the target? And I’d probably disable RVO when they’re maybe a meter or so away.

The best I’m personally able to answer this is that local avoidance only really takes into account local situations, which is how situations like this end up happening. It’s unfortunately not a silver bullet. Deeper than that you start to get into architecture concerns that I don’t personally know.

As far as I know, no. I do want to note that one of the best things about this asset is that it’s extremely versatile- You have a lot of options to “craft your own” local avoidance, especially for that “last mile” movement. I did this for my last game– instead of using RVO I just wrote my own “move away from other enemies” script and then had them use that so it would mesh better with my existing movement system.

That said, if you’d like me to tag Aron to get back to you on this with some suggestions that are a bit deeper than I can provide, I can absolutely do that.