Custom Node A* Pathfinding

Godot Version

4.4.1

Question

Hi there,

I am currently trying to implement AI path finding for a 2d platformer game. I have done the logic for creating nodes on my tile map layer (shown in the image), but I dont know how to get my enemy scene to access the data.

All the visual nodes are calculated in the script attached to my tile map layer.

func on_enter():
player = get_tree().get_first_node_in_group(“player”)

# Dynamically find the TileMapLayerPathFind node in the scene
var root = get_tree().get_root()
var level = root.get_node("TestLevel")
pathfinder = level.get_node("Layers/Ground")

if player and pathfinder and pathfinder.has_method("find_path"):
	path = pathfinder.find_path(character.global_position, player.global_position)
	current_path_index = 0
	playback.travel(walk_animation_name)

If anyone has implemented this type of path finding any tips would be appreciated!.