Is it intended behaviour that _ready is only called once in an instanced scene?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Maxpilot

Loaded a scene as packed scene and instanced it. Kept the instance in memory as a member variable of a superior scene for subsequent access.
Added it to tree: _enter_tree() and _ready() are called as expected. Then removed it from tree, but kept instance. In subsequent adding the instance to the tree _ready() is not called any more, but _enter_tree is. This is not as the doc describes for _ready(): “Called when the node is ready, i.e. when both the node and its children have entered the scene tree”.

:bust_in_silhouette: Reply From: Guilherme Furst

Yes _ready() should be only called when added to tree and all of its children are ready as well.
when instancing, _init() is called instead. Where instance() is the analogous behavior of new(), but for packed scenes.

Double check if you’re really not getting that behavior. If that’s really not the case, then consider filing a bug report.

thanks for answer. Don’t know if this is a bug or for whatever reason intended behaviour. Here a little project that breaks down what I mean. If run in the editor, the results can be seen in the console:


Maxpilot | 2018-03-02 08:03

Just in case anyone runs in the same: Got an answer on Github that this is intended behaviour. “request_ready()” (I put this in _enter_tree() function) will do the trick.

Maxpilot | 2018-03-02 16:57