Getting signal from unknown node

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

Hello everyone!

I want to send signal to player from some nominal node with coordinates of its node, but problem is what player (especially him script) can’t know the name of this node until click and so emitting of signal, because in the scene many the same nodes with nearly-common names.

What can I do to solve it?

Sorry for my bad English and in advance thank for your answers!

are you using a custom signal?

asetyowatir | 2020-11-06 01:28

If buy custom you mean my own with some arguments, yes

Noerigarnhy | 2020-11-06 06:14

:bust_in_silhouette: Reply From: db0

The player must absolutely know of the signal before it is emmited.
Simply connect the signal to the player node during the _ready() function of the node which will emit the signal.
Even if the node was created 1 centisecond before it emits the signal, it will still have time to connect to the player node’s function which that signal must trigger.

Thank for your answer! Do you mean, that I can just connect name of the signal with function inside script and it will work even when player doesn’t know node-emitter?

Noerigarnhy | 2020-11-06 10:25

When you say “the player” do you mean a player node, or the developer of the code?

In any case, yes, you can connect signals through code

db0 | 2020-11-06 11:12