Godot: _ready() only called in first add_child() for instanced scene

Created on 2 Mar 2018  Â·  8Comments  Â·  Source: godotengine/godot

Godot version:
3.0 and 3.01

OS/device including version:
Windows 7

Issue description:
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".
Sorry if I'm wrong.

Steps to reproduce:
Run example code in the editor, the results can be seen in the console.

Minimal reproduction project:
readytest.zip

documentation enhancement

Most helpful comment

This is not a bug, since Godot 3 _ready() is only called once, because most people relied on that. If you need it to be called again, you need to call request_ready() on the node.

This could be added to the docs, though.

All 8 comments

This is not a bug, since Godot 3 _ready() is only called once, because most people relied on that. If you need it to be called again, you need to call request_ready() on the node.

This could be added to the docs, though.

Thank you very much for explanation and btw - Godot is so great, thank you all for this tool.

At which point should we call request_ready()?

Called it in _enter_tree() in my example, that did it.

I'll wait for the doc because I'm unsure if that function schedules the call with a boolean or calls the _ready cascade immediately

You're right, it's not sure

Did test with two subnodes and "request_ready()" in _enter_tree() of root node of added scene. Sequence is:
enter_main - enter_sub1 - enter_sub2 - ready_sub2 - ready_sub1 - ready_main

Remarkable:
Without "request_ready()" in root node _ready() in subnodes are called but not in root node.

Cally on the same _ready() function itself. There was a bug and it doesn't
work in 3.0… I think I fixed it in newer versions

On Mar 2, 2018 17:41, "Maxpilot" notifications@github.com wrote:

Did test with two subnodes and "request_ready()" in root node of added
scene. Sequence is:
enter_main - enter_sub1 - enter_sub2 - ready_sub2 - ready_sub1 - ready_main

Remarkable:
Without "request_ready()" in root node _ready() in subnodes are called but
not in root node.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/godotengine/godot/issues/17182#issuecomment-370046213,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AF-Z21AY5QVtYG2j8JZOYQ4V9JB_Wb9qks5taa5fgaJpZM4SaF-a
.

Was this page helpful?
0 / 5 - 0 ratings