AStarGrid2D enemy movement following the player doesn't work

Godot Version



Hey Godot devs, I’m having a weird bug and wanted to see if someone knows how to fix it:

-I’m using AStarGrid2D for moving [OK]
-Cell size is (32,32) [OK]
-Path[0] returns a weird value, so I must give it to_local(x) and multiply it by 32 to make it “work”.
-Then, the character doesn’t register (Completely ignores) walls. [BUG]
-path is never 1, it keeps saying it’s “32” when it reaches the player. [BUG]

func move_to_player():
	var path = LevelVariables.astar_grid.get_id_path(
	if path.is_empty():
	set_started_moving(true) #true
	position_to_move = to_local(path[0]) * LevelVariables.TILE_SIZE
	path_to_player = path

This is the grid:

func build_grid():
	astar_grid =
	astar_grid.region = Rect2i(0, 0, REGION_WIDTH, REGION_HEIGHT)
	astar_grid.cell_size = Vector2i(32, 32)

I don’t know what to do, I’m not using tilemaps (Don’t know how to use them) and the only stuff online that uses this is with tilemaps

Fixed it!

For anyone wondering, the find id path needs “grid-id” as parameters, not global positions. You need to turn positions to grid-id by dividing them by your cell cize. Then, you make the result a position again (By multiplying them by your cell size)