My child signal dont work when add it programatically in script at my main

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

My child Scene:

Area2D (Add signal on_Area2D_mouse_entered)
L CollisionShape2D (Width 50, Height 50, X 50, Y 50)

Area2D has a script attached with function on_Area2D_mouse_entered. this function show a message: “Im Here”. It is working now (when i move my mouse over area the message is shown). Save scene as Child.tsc.

My Main Scene:

Node2D with attached script.

In script, in ready function i create my instance of child:

var child = load("res://Scenes/Child.tsc").instance()

Now, when i run this scene, my child is created and i can view it in the game screen, but on_Area2D_mouse_entered never is fired when i put my mouse over it

Any help? how can fix it?

can you share a minimal project?

volzhs | 2019-06-16 12:42

:bust_in_silhouette: Reply From: newold

I was able to solve the problem: If you instantiate a scene, whose parent node is an Area2D, the mouse events do not work on it.

To solve it, I used a Control as the parent node in my child scene. Next I had to connect the signals of my child scene with my parent scene with the command child.connect(“child signal”, parent, “parent function”)