Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | sparrow666 |
hello
i’ve been using godot for a while now, i love it! best engine ever!
but i’ve never really got my head around signals, i kinda know how to use them
but i don’t get the point
a signal is a soft coupling so it doesn’t break the game when the connecting object gets destroyed, but… in the receiver code you have to reference the emitter node by
emitter.connect(“custom_signal”, self, “adjust_and_print”)
but that’s a coupling cause you need the find and reference the emitter with
var emitter = get_parent().get_node(“signal_emit”)
if this line fails then the game breaks anyway!
unless the receiver is a child, or a parent of the emitter, in which case i could do this
instead
$receiver.adjust_and_print() or …/ect…
and if not a child or parent then i might as well do this
var receiver= get_parent().get_node(“receiver”)
receiver.adjust_and_print()
why can’t i just do this?
connect(“custom_signal”, self, “adjust_and_print”)
if one node is emitting then surely receivers listening can react?
or have i got it all wrong?
any help or enlightenment would be great!
thanks
oh and ps. i do know that you can connect via the editor it does solve a shed load of the above but i would like the option of doing in code. or i could use the get node, or find by group.