How to listen to signals of dynamically instanced nodes

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

My scene has the following code to instantiate mobs:

var mob = Mob.instance()

So I am instantiating a node. Which comes with a child node (VisibilityNotifier2D) named Visibility.

How can I listen to the screen_exited signal of the Visibility node?

Here is what I tried with the / to query child nodes:

mob/Visibility.connect("screen_exited", self, "_on_Visibility_screen_exited")

Since it is an instance it won’t compile.

:bust_in_silhouette: Reply From: alexzheng

mob.get_node(“Visibility”).connect(“screen_exited”, self, “_on_Visibility_screen_exited” )

Just a typo (it’s mob.get_node()) but it works ! Thank you !

Ploppy | 2018-10-13 12:11