How to get Astar Grid working in isometric

Godot Version

Version 4.2

I am trying to make a tactics RPG and ran into an issue when working with the AstarGrid2D method where it works just fine in a standard top down 2D, but doesn’t work in isometric, is there any fix for this my code is

(on tilemap)

@onready var player = $"../GridTestPlayer/Grid Movement Component"
var astar:AStarGrid2D
var dic = {}
# Called when the node enters the scene tree for the first time.
func _ready():
	astar = AStarGrid2D.new()
	astar.region = get_used_rect()
	astar.cell_size = tile_set.tile_size
	astar.diagonal_mode = AStarGrid2D.DIAGONAL_MODE_NEVER
	astar.update()
	player.astar = astar
	player.tilemap = self
	return
(on player)
var astar: AStarGrid2D
var tilemap: TileMap
var currentIDPath: Array[Vector2i]
# Called when the node enters the scene tree for the first time.
func _ready():
	pass # Replace with function body.
func _input(event):
	if event.is_action_pressed("Select") == false:
		return
	print(":3")
	var id_path = astar.get_id_path(
		tilemap.local_to_map(global_position),
		tilemap.local_to_map(get_global_mouse_position())
	).slice(1)
	
	if !id_path.is_empty():
		currentIDPath = id_path
		print(currentIDPath)

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta):
	if currentIDPath.is_empty():
		return
	
	var target_position = tilemap.map_to_local(currentIDPath.front())
	
	get_parent().global_position = get_parent().global_position.move_toward(target_position, 1)
	
	if global_position == target_position:
		currentIDPath.pop_front()
	pass

the code in action

AstarGrid shouldn’t work with isometric positions, since the class works with a rect grid. You should use Astar2D.

oh okay, are there any tutorials for astar2d for godot 4

This looks like a complete guide for Astar2D:

The essential thing is to add points using add_points() method, giving a unique id and Vector2 position (your tiles positions) and then connect each point with their neighbours (or at least the points that should be connected). After setting everything up, you can call get_point_path() and received an array of positions for you to use in your player movement method. Pretty much what you are already doing in your current code.

AStarGrid2D has a property ‘cell shape’, which can be set to squares but also to two kinds of isometric.

An isometric grid is still a grid. AStarGrid2D would work fine.