Difference between setParent and parent

I’m still confused about the explanation here about setParent and parent
Mesh | Babylon.js Documentation (babylonjs.com)
Mesh | Babylon.js Documentation (babylonjs.com)

Especially about this "The node will remain exactly where it is and its position / rotation will be updated accordingly." for setParent, and Gets or sets the parent of the node (without keeping the current position in the scene) for parent.

Also, does it matter to set mesh position first or set parent first

Could someone explain that in more detail way? Thanks

if you use .parent = the mesh local info won t change so for instance if the mesh position is 0 2 0 and you parent to a mesh being 0 -10 0 your new world position will be 0 -8 0

if you use setParent the mesh will change its local position rotation… to remain at the exact same place in the world despite having a new parent so for instance if the mesh position is 0 2 0 and you parent to a mesh being 0 -10 0 your new world position will be 0 2 0 ( as before ) but your local position will be changed to 0 12 0

2 Likes

What I would see in the scene is world position not local position, right?

yes it is