Get a list of targets from a tilemap

Godot Version

v4.2.1

Question

I am new to Godot and working on a turn based rpg which uses a tilemap. The basic game mechanics are similar to a game like dnd, or pokemon mystery dungeons, with players exploring a randomly generated dungeon and fighting monsters. I have a tilemap with collisions, and an enemy class that walks towards the player when they are within a certain range. Next I’d like to add actions for combat.

Here’s my question: What is the correct way in Godot 4 to find the targets of an attack? My first instinct was that I would have a function on the tilemap I could call with coordinates, and it would return the entity standing on that tile, if there is one, but it doesn’t seem to be the correct solution in this case. My current solution is to use a raycast2d to check for a collider in the adjacent tile, but this only works for basic melee attacks. I eventually want to add spells with different areas, such as a large explosion, or a cone pattern for a breath attack. Should I create an area2d for each attack and look for collisions, as if it were an action fighter?

never mind, it’s about line of sight for attacking
then you will want to raycast to be able to see the player, while the enemy will constantly try to face where the player is (rotation). if the raycast of line of sight is connected/hit the player, the enemy will try to attack