Godot Version
4.22
Question
“signals are used to decouple game objects”. to not call get_parent() all the time.
but I dont understand how it really decouples any thing.
In my example i have createt an entitie that needs to send some text to a label. when i want to connect the signal via code i need to call signal.connect() this methode needs the path to the function it should connect to so again get_parrent().get_parrent() … soooo how does this decouple things?

You can connect Bob2 to your Idle_selected through $state_machine/Idle_selected.signal.connect()
or you can connect it through the editor, which is often preferred.
edit: I missed the text part, you can still connect your Label3D through the editor, signals are often used to send information to anything that will accept it, instead of looking for something specific to accept it; that’s “decoupling game objects”
1 Like
With prefabricated scenes like this, you can connect signals with functions by double clicking a signal in the “Node” tab or right click → “Connect…”, given it’s a Node within the same scene you wanna connect. So there’s no need to connect signals via code there as long as you always want it to be connected by default. (no condition such as “only connect signal if this or that”)
If that Label3D in your scene tree is the label you wanna connect and give the text to, then you can just set up the signal connection within your scene as shown in the screenshot above. (with the signal you want to connect, that is. my image is just an example)
1 Like
Problem with that is that i want to spawn bobs dynamicly later on. (there in here for testing purposes). Like spawning them via script. And then i need the ability to connect via cide don’t i?
Yup, connecting to outside signals will require code. I’d imagine in this scenario you would be adding bobs along side the label right? So the code would look something like this?
var new_bob = BOB_PREFAB.instantiate()
new_bob.signal.connect($Label3D.accept_bob_message)
add_child(new_bob)
The part with to anything that will accept i don’t get. Because it seams to me i need to define to specific Node to accept the signal
Bob doesn’t have to know about Label3Ds to emit it’s signal. Label3D does always have to know about Bob, sad fact of life.
Without the signal Bob has to know where the Label3D is and how to run a function on it.
1 Like
So i need to make the label unique and pass ut down from the parent(bob) to the state? Bc i learned you cant access unique names from other scenes/prefabs
Don’t need a unique label, but you could use one, my example was assuming it is attached to the parent of both Bob and Label3D; so both are a direct child and not outside of the scene, a unique identifer could work, but would be just as short as $Label3D
or $Bob2
Seams like has to know where the label is
i mean you’re passing the position /unique name to it. In your example Or do i miss understand it 
Bob doesn’t, the parent does. Controlling who needs to know what is decoupling.
Aaaaah okay so i need a script in the shared parent node that connects these 2
1 Like