+1 vote

I apologize if this question is silly. I'm extremely new to Godot (and programming in general), and I've just managed to wrap my head around object-oriented programming.

The inheritance tree when it comes to the class of nodes makes sense to me. (Node2D < CanvasItem < Node < Object, that sort of thing.) No problem there.

However, I'm having trouble wrapping my head around parent-child relationships between nodes in the scene tree. Because clearly a child node doesn't inherit the class of its parent or anything. It does seem to be...maybe not "inheriting," but affected in some way by the transforms, visibility, and so on of its parent. If that sort of thing were as far as it went, I think I'd be okay (it seems similar to how "parenting" works in Blender).
It also seems to have some sort of file-system folder sort of thing going on, which I can also understand for purely organizational reasons. (Like how you can in a script treat the node tree like a file path, sort of.)

But then there are some nodes that say they require a certain child and/or parent to function at all. I don't understand at all what's going on here. Do certain nodes just need to talk to other nodes, and have built in "if I have that node as a child, I'm using it" sorts of things going on? Or is there some sort of inherent "this node is MY CHILD/PARENT, and therefore...something!" And why would a node require a child to work at all? I'm so confused.

Scenes as a whole seem to just be a root node with some children, so is any parent node basically just a scene (except not officially called one and maybe missing some of the instance-functionality that comes with it)?

TL,DR: What do parent nodes get from children, and what do child nodes get from parents? Is it only stuff like transforms, visibility, existing-in-the-scene-tree, etc.? Or is there more? I'd appreciate as complete a list as possible. Thanks so much!

Godot version 4.0 Beta 10
in Engine by (13 points)

1 Answer

0 votes

Here's the documentation for Nodes in Godot. Most of the top part discusses how children and parents work.

Though the things you talked about (concerning parents and children) in your question description were all of the main points, and there's not much more other than that for the most part.

by (731 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.