0 votes

I've been trying to create a combat log for my project. For this I made a scroll container with a vbox container as it's child, and added labels as children to the vbox container. For this work as I wanted the labels had to have autowrap On and a fixed minimun size.

This system functions with labels that I add in manually, but every label that I add in through code simply doesn't show up. I've done some testing and the labels seem to be added as children correctly, but you can't see them when the game is running. Also, with the exeption of the label I'm adding in the 'ready()', every time I try to add another I get this error:

E 0:00:04.947 addchild: Can't add child '@@2' to 'VBoxContainer', already has a parent 'h_scroll'.

in Engine by (18 points)

2 Answers

0 votes

Given the message, it looks like the node you are trying to add already has a parent. Make sure you use add_child only once per label. It's possible you have a problem in your code (I've seen this mistake before) where you keep adding the same label?

by (29,046 points)
0 votes

I think I figured it out. The error was being caused because I had created a global variable that had a label with all the modifications to the properties already done, and I was assigning it to the local variables I was using in my functions. Because of that I wasn't creating new labels, but rather changing the text and trying to change the parent of the same label.

by (18 points)
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.