|Topic was automatically imported from the old Question2Answer platform.
Hi, I’m having a very strange issue with my visual novel project.
I have Hud as a CanvasLayer and within it there’s a box for displaying dialogue choices (texture nodes, vbox cont., button, etc). Outside of Hud I have ninepatchrect and texture rect. I created a function where I want to show box with dialogue choices:
if counter == loaded_scene.dialogue_checkpoint:
$Hud/ChoiceBox.visible = true
var choice_counter = 0
for choice in get_tree().get_nodes_in_group("Choices"):
if choice_counter <= loaded_scene.choices.size() - 1:
choice.visible = true
choice_path = choice.get_path()
get_node(str(choice_path) + "/Box/Button").text = str(loaded_scene.choices[choice_counter])
choice_counter += 1
choice.visible = false
$Hud/ChoiceBox.visible = false
And it works. But…
Sometimes, like when I have three or more choices with longer sentences, the background outside of hud flashes with black. It disappears for a moment and comes back. I tried moving everything from hud outside and moving background within the hud, but the issue persists. I tried changing node types of hud, buttons, labels, background, changing the size of nodes so that text can fit… nothing helped. It’s strange that only some nodes disappear. Choices box, dialogue box, a third box where I plan to put some icons, remains there the whole time. I see no connection between them.
Because of that I don’t even know what info to share with you guys so that you can understand the problem better.
If you have some ideas, please help.
Try setting a breakpoint to before you make the first choice visible and stepping through the code to see what it is doing right before the background disappears.
LeslieS | 2023-02-04 17:58
No errors and everything seems to work fine. I don’t see any issues. I found out that number of characters within buttons text somehow affects this. If there’s 16 characters in all three choices, the background blinks. If there’s less than that in at least one, everything is ok. Same happens if I use labels and richtext instead of buttons.
This might not be the real cause but that’s all I notice right now.
Happyman | 2023-02-04 20:50
This one is going to be impossible to debug without looking at it in its entirety.
Can I see a picture the node tree?
LeslieS | 2023-02-04 21:09
NodeTree Rest of nodes named 100 has the same children as the first one.
Happyman | 2023-02-04 21:36
I suspect it has something to do with the
VBox containers auto-aligning contents.
I have struggled with those controls in the past.
I would try to replace those with static sized panels to test that theory. If it is the case then you at least have a clearer direction to start figuring it out.
LeslieS | 2023-02-04 23:09
Ok, I tried with both
Panel nodes, problem is still there. I forgot to mention, the black flash shows only the first time. Meaning, if I shift back to previous dialogue and run on the problematic one again, no flash. Or if I continue playing and reach another checkpoint with dialogue choices, no issue at all. Seems almost like it needs to load something for the first time after running the game and can’t do it fast enough. But when it does it once, next time (in the same session) it works as expected.
Happyman | 2023-02-05 09:17
I’m pretty stumped here now too. If you want to upload the project to github I can look at it.
LeslieS | 2023-02-06 17:31
I got around this by putting
yield timer inside
for loopso that each new choice is displayed 0.1 seconds after the previous and it works. Looks like the problem exists when trying to display all choices at once. I just hope this won’t cause some troubles in the long run. I heard that yield can be used in a wrong way haha.
In any case, thank you for your time and effort to help.
Happyman | 2023-02-07 09:22