0 votes

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!

in Engine by (12 points)

are you using a custom signal?

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

1 Answer

+1 vote

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.

by (85 points)

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?

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.