#How can i connect a signal between 2 scenes

3 messages · Page 1 of 1 (latest)

whole storm
#

i have a script spawn a block (lets call it : BOB) and i need to connect one of BOB signals to the player but BOB didn't exist at the main scene
- The question is how can i connect the signal to the player

tardy stratus
#

load bob scene file (.tscn / .scn):
var bob_scene: Packedscene = preload("res://BOB.tscn")
instance the scene:
var bob_instance: Bob = bob_scene.instance()
add the instance to the tree:
add_child(bob_instance)
connect signal "signal_name" to method "method_name"
bob_instance.connect("signal_name", self, "method_name")

if you want to connect a signal from one instance to a method in another instance:
bob_instance.connect("signal_name", other_instance, "method_name_in_other_instance")