Godot Version
4.3
Question
`Hello,
I have his certain scenario that I don´t understand on how to send a signal up.
Screenshot 1 shows the game tree at the start of the game.
While the game runs, items will be spawned, so a new Node “ItemWave” is being spawned which contains continuously spawned items. You can see the resulting tree in the example in Screenshot 2.
Please ignore that I didn´t add collision shapes since its just an artificial example.
Now when the item area detects the “Player” area, I want to send a signal from the item up to the “Player” node. It would be also ok to send it up to the “GameLevel” node. Please note that the Item node doesn´t belong to the scene at the start of the game.
How can I achieve this? I have tried out the documentation and different forum propositions but I seem to not be able to grasp the concept.
Best regards,
Jayme
Create an autoload global script called something like signal_manager that would look something like this:
extends Node
signal signal_from_item
Then in your item, when you detect the player just emit it.
SignalManager.signal_from_item.emit()
In your player, connect to the signal from the signal manager something like this:
SignalManager.signal_from_item.connect(_on_signal_from_item)
If you want to pass info you should add it into your signal manager like this:
# in signal_manager
signal signal_from_item(ItemScene: Node)
# in item scene
SignalManager.signal_from_item.emit(self)
# in Player scene in collecting function
func _on_signal_from_item(ItemScene: Node):
# Do whatever here
Using the signal manager means your emitting from item will work even when running your item scene by itself. The same for your player, who will always be able to connect to the signal_manager, even if no items exist yet.
Hope that helps and makes sense.
PS Another way to do this is to add a reference to your Player node that you set when you are instantiating the item scene. Then you can just use the player reference to communicate to that node. This is not as robust as using signals though so would recommend the signal_manager.
PPS People often call this a ‘signal bus’, but I prefer the name ‘signal_manager’. You can call it whatever suits you of course.
1 Like
Thank you Paul. Need to go back to work now but I will try it out later!
To be honest I am surprised about the approach. I thought the approach would be something like get_node(“Player”) etc.
This never worked for me. Your approach seems much more reasonable and Chat GPT already explained to me that it is a very robust approach 
Hi, work is such a PITA 
This is a fairly common approach to signalling between components and still maintaining a good separation of concerns. You don’t need every signal you use to be in the signal manager (I have made that mistake in the past) just ones where like in your case you are not sure if the nodes that originate the signals are available or not.
I am glad ChatGPT liked my answer - lol.
Well, ChatGPT approved first, now I approve it too 
I absolutely love this solution. It´s amazing!
Thank you so much! believe it or not it made my day.
A hint for beginners: you have to place “SignalManager.signal_from_item.connect(_on_signal_from_item)” into the -ready() function OF THE PLAYER
1 Like