Trying to find a solution for my enemy navigation getting stuck

Godot Version



I implemented a basic chasing state for my enemy in my 2D Top-Down game. The issue I’m having is since the origin of all my characters are on the feet (for more consistent Y sorting), sometimes my enemy get stuck on corners since it’s collision is above his origin point.
Here is a video showing what’s happening:
And here is my code:

func fixed_update(delta : float):

controller.move_dir = get_direction_to_chase_target(col if col != null else actor_to_chase)

func get_direction_to_chase_target(target_actor) → Vector2:
if target_actor == null:
return Vector2.ZERO
if nav_agent == null:
return Vector2.ZERO
nav_agent.target_position = target_actor.global_position
var current_position = controller.global_position
#Get Next position from Nav Agent Calculations
var next_position = nav_agent.get_next_path_position()
return current_position.direction_to(next_position)

So, how I can I make a proper avoidance system when this happens? I’m thinking about raycasting when this happens but not sure how to implement the actual avoidance.
Increasing the navmesh radius won’t work since it would need a really big radius to avoid this problem completely and it’ll probably cause issues on tight corridors

An agent in pathfinding is a single point, it has no shape.

The “shape” is baked into the surface of the navigation mesh so if you have collision problems you need to fix your navigation mesh or the “point” of your pathfinding agent. Either rebake the navigation mesh with an appropriate agent radius or fix the offset of the “point” of your characters and / or their collision radius. Like instead of having your entire character offset only offset the visuals but not the main node which should stay where your characters center is.