-
-
Notifications
You must be signed in to change notification settings - Fork 21k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamically added subchild in an instanced scene is not duplicated using Node.duplicate() #92829
Comments
does that works properly on 4.2 stable? |
Does this work if you assign |
Yes, it does work properly on 4.2.stable. |
I tried assigning the instanced scene as the owner of the dynamically added label in MRP by using the code below:
and still could not get it working. Moreover, Godot throws new errors in this case at line
|
This behavior is not so much a bug as it is a deprecated practice. Lines 2731 to 2733 in e96ad5a
The behavior of editing an instanced sub-scene in the main scene breaks the encapsulation of Once you modify the node tree structure of a sub-scene through a script, you may also need to modify the node tree structure through a script when copying. You are free to modify the node tree by scripts, but you may need to remember what you did. Some solutions:
From the engine's perspective, we are sure that the node is managed by the user, but we cannot be sure whether it is well managed and which script manages it. If the engine handles it on its own, it may cause multiple duplicate nodes (The engine and script may be doing duplicate work). |
Thanks for the answer, so this seems like an intended behaviour changed for 4.2.2. Just wondering, what is the exact difference between Is it that duplicating with
(by using |
It is risky to manage the node structure in the child scene directly from the parent scene. Why not manage the sub-scene node tree in the sub-scene's scripts? Using The following situations may be common without using the When a script in a sub-scene dynamically adds a node during |
Tested versions
System information
Godot v4.2.2.stable - Windows 10.0.19045 - Vulkan (Mobile) - dedicated NVIDIA GeForce RTX 2060 (NVIDIA; 31.0.15.3699) - Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz (12 Threads)
Issue description
As the title states, nodes[C] added to any child[B] of an instanced scene[A] dynamically are not duplicated when calling Node.duplicate() on [A].
Meanwhile, it works if "[A] is not an instanced scene" or "calling Node.duplicate(7) which does not use PackedScene.instantiate() for duplicating".
For clearify the hierarchy relation, see the attachment below:
which [C] is a dynamically added node
Not sure if this is the desired behaviour with some internal changes inside Node.duplicate() after 4.2.2 rc2.
Steps to reproduce
Minimal reproduction project (MRP)
Test.zip
The text was updated successfully, but these errors were encountered: