AStarGrid2D entity getting stuck on walls

Godot Version



Currently I am using the AStarGrid2D class to navigate a character around my scene. I am able to find a path to the target location, but occasionally my character will get stuck on walls.

My movement code works by looping through an array of points derived from GetPointPath. It works through these points one after another, and once the object has moved within range of the next point, the next point in the array is targeted. However, as you can see in my video, occasionally it will find a path that causes the collider to get stuck - you can see that it moves to a point and then tries to move straight up, rather than moving horizontally around the wall.

Is there any way to set a sort of “buffer” on objects in AStarGrid2D the way you can with NavigationAgent2D to get the entity to avoid obstacles, or is there some way I can get the object to recalculate its path so that it won’t try to walk through walls?

The example video is below: