Hi there,
I'm working on a game where you are a piece of light roaming around space, absorbing other light and talking to other entities.
Currently, the "sky" is composed of a 3x3 matrix of "starfields" - which are area2D's the size of the screen. Each "starfield" randomly has stars added to it when it is instanced. To make things are bit more complicated, the starfields are regenerated with a treadmill mechanism, meaning that when the player enters a new starfield, I rejig the "sky" to be a new site of 3x3 starfields. I mention it because it might have something to do with the problem.
The problem?
Sometimes when I launch the game everything works - the sky renders 9 starfields, and each starfield renders some 1-50 stars. Sometimes it doesn't. In the latter case, all the nodes are added to the tree (they are present when I check in a remote view when the game is running). I'm probably missing some easy way to debug this, but I'm not sure what I could be missing. Could I be using add_child incorrectly?). Here's a bit of code if it helps (I can add more details or link to some devlogs if additional context is useful):
Sky.gd: https://pastebin.com/f2S2BLWw
Starfield.gd: https://pastebin.com/XQhdSzrZ
Thanks for any input!