The hierarchy in the node tree

Godot Version

v4.7

Question

This is a question about the principals of making a good node tree.

I’ve seen people in different tutorial using different node tree structures to achieve the same result. But is there really a crucial difference between the first and the second node tree structure ? What fundamental principals should we follow when using node trees ? Is it a matter of personal style?

Node3D/
├─ StaticBody3D/
│  ├─ MeshInstance3D
│  ├─ CollisionShape3D
Node3D/
├─ StaticBody3D/
│  ├─ CollisionShape3D
├─ MeshInstance3D

Thanks.

Please explain what you are trying to achieve

It’s matter of inheritance.

Depend what are you trying to make, generally there is no right or wrong unless you work with UI nodes which are quite stricter how it will behave.

Generally example 1 is sensible, but it’s nothing wrong with two either, think of it like folder.

If you start working with signals then it might be different where you place collisionshape and area3d.

Hello,
It’s a rather general question. I’m still in the early stages of learning Godot.
The example given is creating a basic 3D cube with collisions and physics.

There’s not really gonna be a specific answer to a generic question unless you have some direct examples of what you are asking for or what you are trying to do

It’s a matter of personal style, and how you are creating the object. All four of these examples will work exactly the same.

Some can be automatically generated by importing a model and adding a mesh during import. Others can be made by adding a CollisionShape3D from a MeshInstance3D and determining whether it is created as a sibling, or a child of a StaticBody3D.

Hello,
thanks for the explication.
For the part of UI, I think of them as the same as CSS, in which the hierarchy is more clear. I will keep an eye on the collisionShape and area3D.
The two trees did work in the same way, for me, I found the first one makes more sense, too, we include all the elements under the class StaticBody3D; the second is more treating the visual element MeshIntance3D independently, which is not wrong, either. Not sure if this will have an affect in the long run. I will see.

Hello,
thanks for the picture !
Yeah, I think so, too, it’s more a personal style, because in my view, nodes seem to have taken on the job of separation. The hierarchical relationships within these structures are led by different point of vue.

I agree with you in many cases. I think I may be not very clear in my previous message. By general, I mean I’m trying to understand the general view (management of codebase) from a basic specific scenario ( node tree of a 3D object).

My point was that you didn’t present any question of what you were looking for for the best layout and what to prioritize, it depends on what you are looking for that’s all

Except, you don’t know what you don’t know.

  1. Are you creating the 3D model in Godot using MeshInstance3D objects?
  2. Are you using CSGBoxes to create the MeshInstance3D?
  3. Are you importing the model?
  4. Does your model have a Skeleton3D?
  5. Does your model have animations?
  6. Are you creating the CollisionShape3D manually?
  7. Are you creating the CollisionShape3D programmatically with one of the Godot features that allows that?
  8. Are you creating the CollisionShape3D on import through an import script?
  9. Are you creating the CollisionShape3D through the Advanced Import Interface??
  10. Are you creating the CollisionShape3D in another program like Blender and importing them?

Answer all those questions, and you will get a specific answer to your question.

You don’t know what you don’t know. Good modem. That’s why I ask questions here to hear insights.
Anyway, thanks for the list. I will look into that.