0 votes

Preload a scene and instantiate it by code and found its child node not having been created or initialized when setting its properties.I know i can use *_deffered() .I wonder, is there a more elegant way to solve this?

Godot version I'm using v3.4.4.stable.official [419e713a2]
in Engine by (14 points)

1 Answer

0 votes

calling instance() also calls init() of new object
calling add_child() also calls ready() of new object, unless it was reparented before.
There is now way around it, and it works pretty well.
If You found a child node, than it was created, wasn't it ? Its init() must have been called, and ready() has been called if it was childed for the first time. I bet You mistook something and did it wrong. Can You specify more what exactly wasn;t initialized in your node ?

by (8,101 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.