Call a function in a node with an reference to it

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

I have a Area2d, and I want to call a function in the script of the parent of the node, who enters the Area2d (body_entered).

How can I do that?

:bust_in_silhouette: Reply From: Zylann

Use get_parent() Node — Godot Engine (stable) documentation in English

# Assuming you connected the `body_entered` signal to this function
func _on_body_entered(body):
    body.get_parent().the_function()