Improve or change pathfinding grid generation

Godot Version

4.1.1

Question

I made a grid generator to find a path within a certain radius. But now I need the cells that are at the site of the obstacle to be removed. This is how I did it at the moment: if the cell is blocked by a body, I lift it up. The counter records how much the cell is raised and removes it if it has risen too high. I think this method is not very good and is not adaptive for different types of landscape. Perhaps someone knows a way to change or improve this method.
Here is my code for one cell:

@onready var cell_area = $Cell_Area

var col
var row
var count = 0

func _ready():
	pass

func _physics_process(delta):
	if cell_area.has_overlapping_bodies():
		self.global_transform.origin.y += 0.1
		count += 0.1 
		if count > 1:
			queue_free()

An example of creating a grid using my method: