# What's the right way to do this?

**URL:** <https://forum.babylonjs.com/t/whats-the-right-way-to-do-this/22958>\
**Category:** Questions\
**Created:** [August 10, 2021, 3:39am UTC](https://forum.babylonjs.com/t/whats-the-right-way-to-do-this/22958 "2021-08-10T03:39:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Antidamage](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/antidamage/32/19857_2.png) [@Antidamage](https://forum.babylonjs.com/u/Antidamage)\
**Post date:** [August 10, 2021, 3:39am UTC](https://forum.babylonjs.com/t/whats-the-right-way-to-do-this/22958/1 "2021-08-10T03:39:52Z")

</div>

I have two skinned models with the same skeleton that I want to play the same animation on.

Is it possible to get them to share an animation group and a skeleton? Or do I have to clone the skeleton?

If it’s the latter, what’s the next step after cloning the skeleton? Do you need to clone the animation group as well?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [August 10, 2021, 9:23am UTC](https://forum.babylonjs.com/t/whats-the-right-way-to-do-this/22958/2 "2021-08-10T09:23:14Z")

</div>

You can reuse the same skeleton:

[https://playground.babylonjs.com/#2YLJ1L#6](https://playground.babylonjs.com/#2YLJ1L#6)

---

<div class="post-metadata">

**Author:** ![Antidamage](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/antidamage/32/19857_2.png) [@Antidamage](https://forum.babylonjs.com/u/Antidamage)\
**Post date:** [August 10, 2021, 9:24pm UTC](https://forum.babylonjs.com/t/whats-the-right-way-to-do-this/22958/3 "2021-08-10T21:24:49Z")

</div>

Does clone() not create a separately processed instance of the skeleton? Looking forward I don’t want to multiply the number of times an animation is processed for a skeleton per item of clothing.

That did work though, thank you. I currently have an asset-loading race condition that ensures it only works about one time in 20 though. I tried calling AssetManager.load() on my parent mesh, then added a new mesh task for the clothing and called load() again but the second load never fires.

Would an asset container be helpful with this?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [August 10, 2021, 10:38pm UTC](https://forum.babylonjs.com/t/whats-the-right-way-to-do-this/22958/4 "2021-08-10T22:38:26Z")

</div>

> [@Antidamage](#):
>
> Does clone() not create a separately processed instance of the skeleton?

No, you can see there’s a single skeleton in the scene (there’s no distinction of skeleton/instance of skeleton):  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/0/e01958b4e51acd28c16e17ef3dffe039a8944db7.jpeg)

All clones are pointing to the same skeleton `Skeleton0`.

> [@Antidamage](#):
>
> Would an asset container be helpful with this?

Hard to tell without a repro… Does it work if you load using `SceneLoader.ImportMesh` or `SceneLoader.Append`?

---

<div class="post-metadata">

**Author:** ![Antidamage](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/antidamage/32/19857_2.png) [@Antidamage](https://forum.babylonjs.com/u/Antidamage)\
**Post date:** [August 10, 2021, 10:57pm UTC](https://forum.babylonjs.com/t/whats-the-right-way-to-do-this/22958/5 "2021-08-10T22:57:47Z")

</div>

I use AssetManager.addMeshTask() so that we can control when loading takes place, but the result is always random whether it is able to find the original skeleton in the scene. Looking at some stuff with promises to make dependent meshes wait, but queueing dependent meshes on success and calling AssetManager.load() again after that doesn’t do anything.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [August 11, 2021, 9:59am UTC](https://forum.babylonjs.com/t/whats-the-right-way-to-do-this/22958/6 "2021-08-11T09:59:42Z")

</div>

Importing meshes through the `AssetManager.addMeshTask` will also load the skeletons (it is using `SceneLoader.ImportMesh` under the hood), so they should be readily available.

---

<div class="post-metadata">

**Author:** ![Antidamage](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/antidamage/32/19857_2.png) [@Antidamage](https://forum.babylonjs.com/u/Antidamage)\
**Post date:** [August 11, 2021, 9:03pm UTC](https://forum.babylonjs.com/t/whats-the-right-way-to-do-this/22958/7 "2021-08-11T21:03:48Z")

</div>

I ultimately solved it by having dependent meshes load inside the MeshTask’s success function as regular SceneLoader.ImportMesh functions. Seems to work well now.
