Cant detect the specifec Area2D

Godot Version

4.2.1

Question

So i’ve wanted to detect the specifec Area2D that the mouse entered:

func _ready():
	$"Me/mBottom 1".mouse_entered.connect(_on_area_2d_mouse_entered)
	$"Me/mBottom 2".mouse_entered.connect(_on_area_2d_mouse_entered)
	$"Me/mBottom 3".mouse_entered.connect(_on_area_2d_mouse_entered)
	$"Me/mBottom 4".mouse_entered.connect(_on_area_2d_mouse_entered)
	$"Me/mTop 1".mouse_entered.connect(_on_area_2d_mouse_entered)
	$"Me/mTop 2".mouse_entered.connect(_on_area_2d_mouse_entered)
	$"Me/mTop 3".mouse_entered.connect(_on_area_2d_mouse_entered)
	$"Me/mTop 4".mouse_entered.connect(_on_area_2d_mouse_entered)
func _on_area_2d_mouse_entered():
	print("Working")
	$PinkCard.position = #I WANT TO REFRENCE THE AREA2D HERE

And i cant really get it to work , any possable fixes that doesnt need me to use more functions ?

bind the area that was entered to the function

	$"Me/mBottom 1".mouse_entered.connect(_on_area_2d_mouse_entered.bind($"Me/mBottom 1"))
func _on_area_2d_mouse_entered(area):

you can probably use a for loop as well to make the code shorter.

2 Likes

Yeah thats amazing it worked
Thanks