Connecting two nodes in two different scenes with a signal

1.you can make use of EventBus autoload https://gdscript.com/solutions/signals-godot/#:~:text=the%20script%20file.-,Global%20Event%20Bus,-In%20GoDot%20we

simply do it like this:
EventBus.gd (AutoLoad)

class_name EventBus 
extends Node

signal send_state(state:bool)

Enemy01 node’s script
at _ready() add
EventBus.send_state.connect(target method)

to emit the signal from idleState node’s script:
EventBus.emit_signal("send_state",true)

2.in idleState node’s script
add
signal send_state(state:bool)

to emit the signal:
emit_signal("send_state",true)

Enemy01 node’s script
at _ready() add
$"EnemyClassNodes/StateTree/IdleState".send_state.connect( target method )

Note: code no.2 might not work as expected, because the idleState node might havent be ready when Enemy01 node’s ready

1 Like