Hello, I am trying to create a 2D game with RTS style movement. I attached a NavigationAgent2D to my unit class. it successfully navigates around the walkable navigation layer i created but the units can't figure out how to move around each other.

Units are meant to have collision with each other, but I want them to not get stuck behind each other. I did searching and found avoidance as the way to get that to work and I have done the following

I also have the following code blocks

func _on_navigation_agent_2d_velocity_computed(safe_velocity):
avoidance_velocity = safe_velocity

and

if avoidance_velocity == Vector2.ZERO:
velocity = direction * move_speed
else:
velocity = avoidance_velocity
move_and_slide()

However, when avoidance is enabled it still just gets stuck, except it kind of jitters back and forth without making progress

4 days later

The path desired distance and target distance is too small. If you read the doc, it is stated that setting it too small or too large can cause jitters. From my experience, using 1 px without some other manual checks will always give issues. Try fiddling with those numbers to find the right balance.