Moving bone to different skeleton

If I load 2 rigged meshes, is there a way to remove a bone from one skeleton and attach it to the other skeleton?

I know you can simply set a bone’s parent to a bone from the other skeleton, but I feel like more needs to be done 'cos its still part of the first skeleton.

Hmmm I think you’d have to recalculate all of the skeleton matrices :thinking: @bghgary do you have an idea of how to do that?


I can’t say I’ve tried to do this before. It doesn’t sound easy. Why do you want to do this?

1 Like

I want to have bodyparts that users can select and attach to eachother to create an avatar. So basically all bodyparts will have their own skeleton, but when they merge they all need to become one skeleton so animations will work

Maybe @PatrickRyan has suggestions? I don’t think this will be an easy task.

Is it possible I could create a new bone for the main skeleton and copy the matricesWeights and matricesIndices to that?

It’s not just the weight and indices. You need to recompute the bone matrices to make the skin work correctly. DCC tools do a bunch of math to solve this, but I don’t how it works.

@ozRocker, I think this problem needs to be solved at the art level. I don’t think changing the node hierarchy of different skeletons is likely to produce good results at runtime because of the complexity of working the new bones into the bind pose of the other skeleton.

I think the best method, if I understand the question correctly, is to author the swappable parts on their own. They don’t need to be in separate files, but I believe that they need to be skinned to their own copy of the skeleton. For example, if you wanted to be able to switch arms on a character, you would have one skeleton with torso and leg meshes and another for each arm variation. Then you just instantiate the arms you want with the torso and make sure all the skeletons are in the same place. If they all have the same animations, you can just play the needed animation on all skeletons. If not, or you are pulling in animations from a different file, you can retarget the animations to each skeleton and they should all stay in sync.

Not sure if this is what you are looking for, but it seems like a pipeline that is more repeatable and still offers some flexibility.

Sounds like Patrick’s solution is the right one. But reminded me of a similar problem i was working on a while ago to load a mesh and then apply an existing skeleton (with animations) to it. Deltakosh helped me get it working. See thread here: Unexpected Skeleton/Bones from exported Blender file - #16 by Deltakosh. Starting at “So technically, you should be able to only change the skeleton property of your mesh”

1 Like

So with this solution I would end up with a skeleton for every body part? Would there be an issue with performance/memory if I do this?

I think it depends on how complex your scene would be. It’s an easy thing to test out in your scene with the performance profiler where you can track things like active bones, FPS, and more:

I think using this to help understand where the load is coming from as you increase the complexity of the scene would be useful knowledge. We also allow export of the data to CSV, so you can take measurements over time and compare as you grow the scene.

Its a shame I can’t consolidate into one skeleton

I think the only way you would be able to apply the meshes to one skeleton is going to be more of a path of retargeting the mesh skinning to a new skeleton through code rather than to try to break apart skeletons and recombine them. But I don’t even know if that would possible or efficient as you would have to make sure that the bind poses were identical for something like that to even work or you will end up with a mesh that starts in a different position in relation to the bone than expected. I am digging more into our animation systems so if I come up with a method in the future, I will bring it to the forum.

.Animation Retargeting in Unreal Engine | Unreal Engine 5.0 Documentation

.Using Retargeted Animations | Unreal Engine Documentation

These two articles have a good explanation of the process in unreal, with a seemingly similar system to babylon.

From what i can tell, they group the runtime data derived from the model file into a hierarchy above skeleton called a rig, something like:

    <skinning (derived)/>
    <parenting (static, but partially applied)\>
    <bone animation (derived)/>
    <bone rotation (static from model file)/>

Also note they selectively apply the transforms to the parent hierarchy when swapping the skeleton, which seems similar to how babylon forces you to walk the submeshes. This is for leaf nodes with IK. I think it’d actually be really helpful to have an IK target or something built into the rig, primarily considering the case of a character grabbing a weapon with hand ik.

I got it working. I followed @PatrickRyans advice and made sure all bodyparts had the same skeleton. When loaded in the same scene I could just set skeleton of source mesh to same as dest mesh and parent source mesh to dest mesh. Worked! All on the one skeleton. Can dispose of old skeleton no problem