godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.46k stars 21.27k forks source link

Resource.local_to_scene in an array or dictionary does not work for child nodes that have been instantiated in PackedScene or at runtime #97400

Open luuuuyang opened 2 months ago

luuuuyang commented 2 months ago

Tested versions

v4.3.stable.official [77dcf97d8]

System information

Godot v4.3.stable - Windows 10.0.22631 - Vulkan (Forward+) - dedicated AMD Radeon RX 7900 GRE (Advanced Micro Devices, Inc.; 32.0.11037.4004) - AMD Ryzen 7 7800X3D 8-Core Processor (16 Threads)

Issue description

Although #71578 #87268 fixes some similar issues, I'm still experiencing other issues.

  1. The resources on the parent node are independent and as expected, whether stored in a variable or in an array or dictionary, whether they have been instantiated in the packedscene or at runtime.

  2. The resources on the child nodes stored in a variable are independent, while stored in array or dictionary are not independent, whether they have been instantiated in the packedscene or at runtime.

  3. Also during testing, I found that in addition to the second issue, the get_local_scene method of a resource that has been instantiated in packedscene points to the node that was instantiated at runtime, and which confused me.

Output

``` Godot Engine v4.3.stable.official.77dcf97d8 - https://godotengine.org Vulkan 1.3.287 - Forward+ - Using Device #0: AMD - AMD Radeon RX 7900 GRE Comparison of parent nodes already in the packedscene Node: -9223372008031517431 Node: -9223372007914076908 Node: -9223372007897299696 -------------------------------------------------------- Node2: -9223372007863745269 Node2: -9223372007746304758 Node2: -9223372007729527521 Comparison of child nodes already in the packedscene Node: -9223372007964408546 InstantiatedNode2: -9223372007427537624 InstantiatedNode2: -9223372007410760407 -------------------------------------------------------- Node2: -9223372007796636382 InstantiatedNode2: -9223372007427537624 InstantiatedNode2: -9223372007410760407 Comparison of instantiated parent nodes InstantiatedNode: -9223372007645641444 InstantiatedNode2: -9223372007494646493 InstantiatedNode2: -9223372007477869293 -------------------------------------------------------- InstantiatedNode2: -9223372007511423727 InstantiatedNode2: -9223372007494646493 InstantiatedNode2: -9223372007477869293 Comparison of instantiated child nodes InstantiatedNode: -9223372007578532576 InstantiatedNode2: -9223372007427537624 InstantiatedNode2: -9223372007410760407 -------------------------------------------------------- InstantiatedNode2: -9223372007444314841 InstantiatedNode2: -9223372007427537624 InstantiatedNode2: -9223372007410760407 --- Debugging process stopped --- ```

Steps to reproduce

  1. Run project (F5).
  2. Observe the console output.

Minimal reproduction project (MRP)

resource-local-to-scene-test.zip

LuciaSelvlysende commented 1 month ago

I think I'm also having this exact issue.

LuciaSelvlysende commented 1 month ago

I did a little bit of testing for this, duplicating the resources manually also does not seem to work.