I am trying to instantiate a child node called Text.
The main _ready() function will load a text file and store it as a list of words.
It will then use one of the words from the list to create a Text child.
The Text child can emit signals that will update the HUD.
I’ve created a TODO to mark where I only expect 1 Text object. This object should contain the word that I set. But instead, I have 2. The second child has null
Why do 2 Text child nodes seem to be created? Even though I only expect 1?
According to your main.tscn file, you already have one Text node as a child of your Main scene. Instead of instantiating another one, you could just update the existing one or alternatively remove the existing one and instantiate a new Text node at runtime.
Awesome. Removing the Text node in the Scene panel on the side seems to stop the extra child. That’s fantastic. Thank you!
However, a new problem has started. The score doesn’t update. It seems like the signal which was in the Text node and emitted on keypress, is not being received by the HUD node.
When I add a child, do I also have to reconnect the signals? Like this?