# Attach animation to the glb from another glb file

**URL:** <https://forum.babylonjs.com/t/attach-animation-to-the-glb-from-another-glb-file/33696>\
**Category:** Questions\
**Created:** [September 6, 2022, 7:26am UTC](https://forum.babylonjs.com/t/attach-animation-to-the-glb-from-another-glb-file/33696 "2022-09-06T07:26:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [September 6, 2022, 7:26am UTC](https://forum.babylonjs.com/t/attach-animation-to-the-glb-from-another-glb-file/33696/1 "2022-09-06T07:26:35Z")

</div>

Hi everyone  
is it possible to have a file with the 3D model on the one hand, and a file with only the animations on the other.  
I have two glb files, the first one is contains of skeleton and two animations and the second one is contains of the avatar with the same skeleton, i want to know how can i attach the first glb file animation to the second glb file? i mean i want to add the walking animation in the first glb to the second glb. here is my PG: [https://www.babylonjs-playground.com/#G187QX#1](https://www.babylonjs-playground.com/#G187QX#1)

---

<div class="post-metadata">

**Author:** ![Takemura](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/takemura/32/25836_2.png) [@Takemura](https://forum.babylonjs.com/u/Takemura)\
**Post date:** [September 6, 2022, 10:45am UTC](https://forum.babylonjs.com/t/attach-animation-to-the-glb-from-another-glb-file/33696/2 "2022-09-06T10:45:10Z")

</div>

To my knowledge, there are atleast two possible ways to do this:

**1. animationGroup.clone()-function:**

> **[AnimationGroup | Babylon.js Documentation](https://doc.babylonjs.com/typedoc/classes/BABYLON.AnimationGroup#clone)**
>
> Use this class to create coordinated animations on multiple targets \[API\]

If bone names are identical on both skeletons (else you have to rename), the targetConverter would look similar to this:

```auto
(target) => {
     let idx = skeletons1[0].getBoneIndexByName(target.name)
    return skeletons1[0].bones[idx]
}

```

**2. create animationGroup and add animations with targets:**

```auto
var newAnimationGroup = new BABYLON.AnimationGroup("newGroup");
for (var {target, animation} of importedAnimationGroup.targetedAnimations) {
    newAnimationGroup.addTargetedAnimation(animation, newTarget);
}

```

Playground of carolhmj:

> **[Babylon.js Playground](https://playground.babylonjs.com/#97LQS4%231)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [September 6, 2022, 12:12pm UTC](https://forum.babylonjs.com/t/attach-animation-to-the-glb-from-another-glb-file/33696/3 "2022-09-06T12:12:19Z")

</div>

Great, thank u so much
