# Skeleton Animation issue

**URL:** https://forum.babylonjs.com/t/skeleton-animation-issue/43861
**Category:** Questions
**Created:** [September 5, 2023, 10:47am UTC](https://forum.babylonjs.com/t/skeleton-animation-issue/43861 "2023-09-05T10:47:11Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![nogalo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nogalo/32/120_2.png) [@nogalo](https://forum.babylonjs.com/u/nogalo)
#### Post date: [September 5, 2023, 10:47am UTC](https://forum.babylonjs.com/t/skeleton-animation-issue/43861/1 "2023-09-05T10:47:11Z")

</div>

Hi.

I have the following situation.

I have a character loaded into the scene using ImportMesh. I am also loading animations into the scene using ImportAnimations.

The issue is that once animation is applied it completely deforms the original mesh. Here is the playground with my exact situation and files.

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

I am not sure how to proceed with the issue. There is slight difference between skeleton of the original mesh and skeletons of the animations (root bones).

I attached the both files used in here if it helps inspect the problem.

Thanks, any help appreciated

[assets.zip](https://forum.babylonjs.com/uploads/short-url/rBCQ19eO5jx6YQcKyn9hXuEflIh.zip) (7.5 MB)

---

<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: [September 5, 2023, 11:34am UTC](https://forum.babylonjs.com/t/skeleton-animation-issue/43861/2 "2023-09-05T11:34:42Z")

</div>

It seems the skeleton and the animation is ok, as the skeleton debug view is ok:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/5/4/5455224300f75abdfbb59c5735748e412a11a6e5.png)

So, it would be the skinning of the meshes to the skeleton which is wrong.

If so, I think it can only be fixed in the DCC tool.

cc @PatrickRyan in case he would have some advices for you.

---

<div class="post-metadata">

### Author: ![nogalo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nogalo/32/120_2.png) [@nogalo](https://forum.babylonjs.com/u/nogalo)
#### Post date: [September 5, 2023, 12:06pm UTC](https://forum.babylonjs.com/t/skeleton-animation-issue/43861/3 "2023-09-05T12:06:34Z")

</div>

But with the original mesh skeleton “web\_avatar.glb”, if I manually rotate the bones the mesh is following perfectly. Doesn’t that indicate that skin is fine? Shouldn’t imported animation just drive the existing skeleton, which is working fine with the mesh?

Does imported animation skeleton replaces the original skeleton on the mesh?  
Maybe need some way of retargeting properly?

---

<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: [September 5, 2023, 2:11pm UTC](https://forum.babylonjs.com/t/skeleton-animation-issue/43861/4 "2023-09-05T14:11:08Z")

</div>

Ah, it could be a retargetting problem, indeed!

Let me have another look.

---

<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: [September 5, 2023, 7:44pm UTC](https://forum.babylonjs.com/t/skeleton-animation-issue/43861/5 "2023-09-05T19:44:38Z")

</div>

Ok, so the problem is with the skeletons that don’t have the same hierarchy, so there’s no correspondance between bone B1 at index i in the skeleton S1 and bone B2 at index i in skeleton S2.

Actually, there’s only a shift of one bone between both skeletons: skeleton S1 from `walk.glb` has an additional bone (“Armature”) at the root compared to the skeleton S2 of the avatar. Note that there’s an additional bone named “Joint1” in S1, but this one does not count because it has an index of -1, so it is not really used in the bone hierarchy.

It means we can make the meshes that have S2 as their skeleton use the skeleton from S1 by adding 1 to the bone indices in the “matricesIndices” vertex data:

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

Note that there is a problem with the eyes (left and right) because S1 don’t have those bones. As they are located at the end of the skeleton (indices 52 and 53 in S2), they are not a problem for the animation (which animates only bones from 0 to 52 in S1), but because they don’t have animation data, they don’t animate properly.

---

<div class="post-metadata">

### Author: ![nogalo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nogalo/32/120_2.png) [@nogalo](https://forum.babylonjs.com/u/nogalo)
#### Post date: [September 6, 2023, 5:39pm UTC](https://forum.babylonjs.com/t/skeleton-animation-issue/43861/6 "2023-09-06T17:39:46Z")

</div>

Amazing @Evgeni_Popov. Thank you so much. This is very helpful for the project I am working on. Me and my team will make changes on the skeleton to fix the eye issue.

Really appreciated.  
Thanks
