turning a Node2D invisible does not apply to it's base-class-Node children – these stay visible. Changing their type to Node2D then makes them become invisible along with the parent.
I see that a base-Node cannot be turned invisibe, but having some buried deep within my scene-tree, I wonder if it wouldn't be practical to have them adopt the behaviour of their parent in such a case.
Is there a reason for this behaviour? And can I somehow make a Node get invisible in such a case as well?
The Inheritance chain for a Node2D
looks like this:
Node2D < CanvasItem < Node < Object
The visibility
property is on the CanvasItem
. So, the Node2D
has that property because it inherits from CanvasItem
. A Node
does not have a visibility
property, and therefore, it's not possible to set such a property there.
Additionally, a Node
item by itself is not visible in-game. That is, there's nothing rendered for it by default.
Sprite1
Node2D
Sprite2
If you turn off visibility of Sprite1
, then Sprite2
is also made invisible.
However, with this structure:
Sprite1
Node
Sprite2
Turning off the visibility of Sprite1
does not impact the visibility of Sprite2
.
(Thanks to Jgodfrey on godotengine.org!)