Connect Instanced Nodes with signals

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

I have this scene structure:


Then I instance another Node with this code:

onready var PLANTAGE = preload("res://Waffen/Plantage.tscn")
var new_Plantage1 = PLANTAGE.instance()

How can I connect a signal from Dungeon with the instanced Node?

:bust_in_silhouette: Reply From: njamster

You don’t mention which node the script is attached to. Nor the name of the signal. So I’ll assume the script is attached to your Dungeon-node and you want to connect the signal “fire” it’s emitting to a function called “burn” in your Plantage-scene:

connect("fire", new_Plantage1, "burn")

Also take a look at this!

I tried it on another thing and it dont works. This is what I wrote in the Dungeon Script:

onready var CONTAINER = preload("res://Scenen/Container.tscn")
var new_Container = CONTAINER.instance()

signal Stop

func connect_to_Container(container_node):

And this on the Conatiner Node:

func delete():
    print("It works")

But it dont print anything. What is my mistacke?

Godot_Starter | 2020-02-29 12:51

It has to be

self.connect("Stop", container_node, "delete")


container_node.connect("Stop", container_node, "delete")

The former connects the “Stop”-signal of the Dungeon-script with the delete-function of the Container-script. The latter connects the “Stop”-signal of the Container-script with the delete-function of the Container-script.

njamster | 2020-02-29 13:16

Thanks, now it works!

Godot_Starter | 2020-02-29 15:32