How to get the Area2d node of one that was just entered?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Illyas_Onii

I have this code here:

   for c in self.get_children():
		if self.get_children().size() > 0:
			c.connect("body_entered", self,  "nextDialogue")

what I would like to know, is that if and how could I take the body_entered signal, and get the node of that area2d that was entered. I don’t really need to know the body that entered it, just the area2d.

Bonus points: Is there a better way to trigger an event? each of my area2Ds have a string on them that lets me assign which event to start when the player enters that area. I’d love any feedback and/or a better idea!

I suppose something else if its possible, is if I can modify the existing body_entered signal so that I can also pass itself through code. I’d really like to be able to not spend a lot of time connecting code, or doing something complicated.

Illyas_Onii | 2021-05-07 23:06

:bust_in_silhouette: Reply From: Illyas_Onii

so i didn’t expect this to work, but i simply did this in the connect statment:

c.connect("body_entered", self,  "nextDialogue", [c], CONNECT_ONESHOT)

and in my function nextDialogue():

func nextDialogue(body, c):
	print(c.name)