As mentioned in the title, when I want to call the “.children” function on an entity that has children generated by a script, I got an empty array. When I want to call one of the children, I got an empty result (undefined).
However, when I manually place these sub-objects in the editor and try to get, it can return the array normally.
Is this a bug or…? Any suggestion? I got a little sick of this problem .
Can you share the project please?
sure, here is the link of my project
I think that’s to be expected, your SpawnEntities entity comes last in the hierarchy, and it will spawn entities after the cameraPath.js initialize method ran.
So when you print the console log in that script, indeed the children property is empty.
If you try printing it at a later time you will see it filled, here is me doing this in the browser console:
i think you are right, when i call function ‘createPath()’ in postInitialize, it runs good
so it is useless to adjust the script loading order in the scene settings, right?
So the scripts loading order defines the order in which your scripts are getting attached to the applications (to the HTML document).
That is useful for example when you are attaching 3rd party libraries that execute outside of the main app cycle (initialize/postInitialize). In that case putting them on top of that list will make them available to be referenced in your scripts.
The initialize/postInitialize/update execution order will always be from the first entity in your hierarchy to the last one.
although there are still some doubts, but I roughly understand, thank you very much for your answers