Behaviour parenting

I would like to create a mesh child of a parent mesh.
If I make one mesh parent to the other, the positions remain the same. (sphere1.parent = sphere2;)
If I do it the other way around, the child mesh moves. (sphere2.parent = sphere1;)
Why does this happen and how can I ensure that the position remains the same if sphere2 is parent?

When you change .parent, the position of the mesh itself is not in the referential of its parent hence the move.

If you want to retain your current world setup during the attachment to a parent, you can use the setParent function instead.


Example -


Thanks, it works! The only thing is that it doesn’t work as I hoped.

Now the selected meshes all rotate around the center of the last selected mesh.
What I actually want is to rotate the selected meshes around the middlepoint of this group. How could this be?

And is it the right method to apply by parents and children? Or is another method better?

You could use a pivot or a Transform node to change their center of rotation :slight_smile: Parents and Pivots | Babylon.js Documentation (


thanks again, it works!