# How to import animation groups, then assign them to different meshes

**URL:** <https://forum.babylonjs.com/t/how-to-import-animation-groups-then-assign-them-to-different-meshes/36187>\
**Category:** Questions\
**Created:** [December 2, 2022, 5:40am UTC](https://forum.babylonjs.com/t/how-to-import-animation-groups-then-assign-them-to-different-meshes/36187 "2022-12-02T05:40:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![the](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/the/32/28353_2.png) [@the](https://forum.babylonjs.com/u/the)\
**Post date:** [December 2, 2022, 5:40am UTC](https://forum.babylonjs.com/t/how-to-import-animation-groups-then-assign-them-to-different-meshes/36187/1 "2022-12-02T05:40:53Z")

</div>

Hi! I have two character meshes, both with identical skeletons. I’m wanting to import another .glb file containing animations for these characters, and then “assign” these animations to each character. This is what I’ve gotten so far:

```auto
//Import first character
BABYLON.SceneLoader.Append("", base64Uri, scene, (result) => {});

//Import second character
BABYLON.SceneLoader.Append("", base64Uri2, scene, (result) => {});

//Import animation(s)
BABYLON.SceneLoader.ImportAnimations(
    "folder/",
    "animations.glb",
    scene,
    (result) => {}
  );

```

All this does is play one of the animations for one character. How do I play the animation(s) for both characters, or assign an animation to character one, and another animation to character two? Basically, I just need to know how to manipulate my animation.glb once it’s been imported into the scene. Any advice is welcome!

---

<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:** [December 2, 2022, 12:18pm UTC](https://forum.babylonjs.com/t/how-to-import-animation-groups-then-assign-them-to-different-meshes/36187/2 "2022-12-02T12:18:00Z")

</div>

I mentioned two ways how you can achieve copy animationgroups, in here:

> [@Attach animation to the glb from another glb file](https://forum.babylonjs.com/t/attach-animation-to-the-glb-from-another-glb-file/33696/2):
>
> To my knowledge, there are atleast two possible ways to do this: 1. animationGroup.clone()-function: If bone names are identical on both skeletons (else you have to rename), the targetConverter would look similar to this: (target) =\> { let idx = skeletons1[0].getBoneIndexByName(target.name) return skeletons1[0].bones[idx] } 2. create animationGroup and add animations with targets: var newAnimationGroup = new BABYLON.AnimationGroup("newGroup"); for (var {target, animation} of impor…

---

<div class="post-metadata">

**Author:** ![the](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/the/32/28353_2.png) [@the](https://forum.babylonjs.com/u/the)\
**Post date:** [December 3, 2022, 9:22pm UTC](https://forum.babylonjs.com/t/how-to-import-animation-groups-then-assign-them-to-different-meshes/36187/3 "2022-12-03T21:22:07Z")

</div>

Hi! Thanks for your reply. I tried using method number two in this playground: [https://playground.babylonjs.com/#AHQEIB#1825](https://playground.babylonjs.com/#AHQEIB#1825) but for some reason it’s not working.

The result is, as you’ll see, that parts of the character mesh simply just get displaced. I’m still very new to animation in Babylonjs, so I apologize of I’m missing something obvious. Thanks in advance.

---

<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:** [December 5, 2022, 1:12pm UTC](https://forum.babylonjs.com/t/how-to-import-animation-groups-then-assign-them-to-different-meshes/36187/4 "2022-12-05T13:12:50Z")

</div>

I assume your animations target bones not meshes.

So get the skeleton you want to animate on outer scope and use their bones as target like this:

```auto
newGroup.addTargetedAnimation(animation, globalSkeletons[0].bones.find(bone => bone.name === target.name))

```

Also I would exchange setTimeout with scene.onReadyObservable:

> **[Scene | Babylon.js Documentation](https://doc.babylonjs.com/typedoc/classes/BABYLON.Scene#onReadyObservable)**
>
> Represents a scene to be rendered by the engine. \[API\]

What I would check aswell is if using stop() on animationGroup can be enabled by play() or rather start()-function. From what I remember start() is opposite of stop() and play() is opposite of pause().

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [January 4, 2023, 12:32pm UTC](https://forum.babylonjs.com/t/how-to-import-animation-groups-then-assign-them-to-different-meshes/36187/5 "2023-01-04T12:32:27Z")

</div>

Hello @the ! Just checking in if you need any more help with this?
