0 votes

Hello guys

So... I created a singleton code that will carry all signals that i will be using in project. Then if a node needs to connect with other node, it will need to call the Signal_bus as the example below:

->Signal_bus.gd:

signal start_conversation

->Textmanager.gd (codeA):

Signal_bus.connect("start_conversation", self, "initiate_conversatrion")

->Scene1.gd (codeB):

Signal_bus.emit_signal("start_conversation")

If the example wasn't clear enough, here is the tutorial that i'm watching.
The following image is how i'm building my node's hierarchy: My node's hierarchy

The emission of signal coming from codeA to codeB is working and it activates codeB's functions properly.
But i need that code
B emits a signal to activate some print text funtions carried by code_A and its not working.

Someone has any clue about what is happening?

in Engine by (17 points)

1 Answer

+1 vote
Best answer

The emission of signal coming from codeA to codeB is working and it activates codeB's functions properly.

I think you got a bit confused there mate. The code example you provided emits a signal from codeB to codeA. If you need that the direction of the emission goes the other way around, you need to connect the signal in codeB instead.

I am not getting the use you're getting out of this system though. Are you sure you need this kind of complexity for what you want to do and can't just depend on normal callbacks to provide you with the functionallity you need?

Signals are useful but I'd try not tu abuse them or your code can get real messy real fast.

by (380 points)
selected by

I think you got a bit confused there mate. The code example you provided emits a signal from codeB to codeA. If you need that the direction of the emission goes the other way around, you need to connect the signal in codeB instead.

I need the code to work as in the example i gave: Scene1(B) must emit the signal connected to a function in Text_manager(A).

I made the connection from A to B just for test. And it worked in this direction, but not the oposite.


I am not getting the use you're getting out of this system though. Are you sure you need this kind of complexity for what you want to do and can't just depend on normal callbacks to provide you with the functionallity you need?

I'm using this system because the scenes will be replaced by code. When i tried to do it in a "regular way", using gettree().getnode() for example, i got lost about how to use the connect with a variant path.

I think I know where your issue comes from. Remember the code in your scripts execute in the order the nodes are added in the scene, from upwards to bottom. So you'd need the connect code to execute before the signal is emitted when your scene is added. So, i'd move the Text_manager node to before the ViewportContainer node.

I strongly recommend that you handle your scene hierarchy and instancing differently because this will become tricky when your scene grows and if you need Z positioning which is not the intended one for this script loading order to work.

I strongly recommend that you handle your scene hierarchy and instancing differently because this will become tricky when your scene grows and if you need Z positioning which is not the intended one for this script loading order to work.

I will be careful about it.


Following your recommendation i changed my hierarchy and it worked. Thank you, bro.

No problem, glad to be of help. Good luck!

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 Frequently asked questions and 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 [email protected] with your username.