Description
Tested versions
Tested with Godot 4.4.1-stable, on Windows only
System information
Godot v4.4.1.stable - Windows 11 (build 26100) - Multi-window, 2 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3080 Ti (NVIDIA; 32.0.15.7270) - AMD Ryzen 9 5900X 12-Core Processor (24 threads)
Issue description
The following setup is basically what I have seen in my game project:
Note that some_object
is not marked with a unique name. In the original project that was a mistake, but the bug made it very much harder to spot, because it finds a node from somewhere else and manipulates it, which lead to surprisingly obscure behaviors.
Here is a scene using that A scene as a subscene:
Note that some_object
is marked with a unique name.
The script from A
's node:
extends Node2D
@onready var some_object = %some_object
func _ready() -> void:
print("some_object = ", some_object)
if some_object:
print("where: ", some_object.get_path())
results in:
some_object = some_object:<Node#29276243270>
where: /root/main/some_object
But we expect:
some_object = null
This behavior directly contradicts the documentation:
Both the tooltip and the documentation for unique scene names explicitly specifies that in this case the scene A
being a subscene should not find a node which exists outside of it's children, same name or not.
Steps to reproduce
In a new project:
- create a main scene
- create another scene, say
A.tscn
- in
A
scene, add a child node and name itsome_object
DO NOT MAKE IT UNIQUE - add the script above to
A
's root node - add
A.tscn
as child node of the main scene - add a
Node
to the main scene with the namesome_object
and make it a unique scene name - run the project