Mesh transforms when attached to bone

Hi everyone,

I’m creating creatures which are ‘modular’. There’s a standard round-ish body which I animated (poorly) in blender and I’m able to import it into the game with a skeleton & animation groups.

I’m struggling however with the modular part. I created a bunch of “tails” in Blender in separate glb files and am able to import them into the game as well. When I attach the tails to the correct bone from the skeletong, they follow the animation. So far so good :slight_smile: .

The problem is, the tails also transform when attaching to the bone and I don’t understand why or how to counter these transformations.

I’m unsure where to look for the correct information.
I’ve checked the documentation of Bones (Babylon.js docs)
And looked into Parents & Pivots too (Babylon.js docs).

All I want is for my mesh to follow the bone, but not be transformed initially when attaching it. I just can’t seem to wrap my head around this.

All help is much appreciated!


Hello :slight_smile:

If you have a look at this topic : Walking on Snow I’m attaching some cubes to the foots in order to create the walk on snow behavior :

(Cubes visible)
(Cubes invisible)

I had to deal with placing the cubes at the right place regarding the foots.
It’s basically a matter of transform :

box.position = new BABYLON.Vector3(4.5,3.5,-0.5+index);
box.attachToBone(skeletons[0].bones[id], dude);

:arrow_right: Playground

If you go box.position = new BABYLON.Vector3(0,0,0); the box center will match the exact position of the bone. So it means box.position becomes a relative position regarding the bone, after box.attachToBone. You can have a look at the freezed version for better understanding

Hope it will help :slight_smile:


1 Like

Hi @Tricotou,

Thanks for the reply. Although your answer didn’t really answer my question directly, this statement did make it click for me!
So it means box.position becomes a relative position regarding the bone, after box.attachToBone .

I was able to fix it after I realised that the above statement also applies to scaling and rotation!
The skeleton I created in Blender contains bones which have their own scaling, rotation and position. The position was easily corrected thanks to your statement, and after fixing the Scale and rotation in Blender the meshes now follow the animations without being transformed to oblivion!