# I give a try to GLTF But everything goes wrong for the animations

**URL:** <https://forum.babylonjs.com/t/i-give-a-try-to-gltf-but-everything-goes-wrong-for-the-animations/32744>\
**Category:** Questions\
**Created:** [August 3, 2022, 4:13pm UTC](https://forum.babylonjs.com/t/i-give-a-try-to-gltf-but-everything-goes-wrong-for-the-animations/32744 "2022-08-03T16:13:49Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [August 3, 2022, 4:13pm UTC](https://forum.babylonjs.com/t/i-give-a-try-to-gltf-but-everything-goes-wrong-for-the-animations/32744/1 "2022-08-03T16:13:49Z")

</div>

Hello,

I always use the babylon extension to load my 3d models. And today I wanted to give gltf a try to load my characters to see how it would perform in terms of performance. (the character seems to load much faster, which is cool)  
I’m hitting a wall with animations now.  
I understood that there is an animation group now. But I don’t understand how it works.  
I was able to stop all animations with `animationGroups[0].stop();`

But then I’m lost.

Before I used:  
`avatar.skeleton.createAnimationRange('walk', 0, 100);`  
Then I could play the animation with:  
` avatar.skeleton.beginAnimation('walk', true, 1.0);`

with gltf and animation groups I no longer understand. I have a single animation from 0 to 3000 (which represents several different animations, but joined into one.)  
Can I still use `createAnimationRange()`?

How can I give a name and a start and end key with animation groups as I did with `createAnimationRange()`

Thanks for your help

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [August 3, 2022, 4:27pm UTC](https://forum.babylonjs.com/t/i-give-a-try-to-gltf-but-everything-goes-wrong-for-the-animations/32744/2 "2022-08-03T16:27:34Z")

</div>

cc @bghgary

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [August 3, 2022, 5:14pm UTC](https://forum.babylonjs.com/t/i-give-a-try-to-gltf-but-everything-goes-wrong-for-the-animations/32744/3 "2022-08-03T17:14:32Z")

</div>

Do you have a playground? I’m not sure I understand what you mean.

---

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [August 3, 2022, 5:17pm UTC](https://forum.babylonjs.com/t/i-give-a-try-to-gltf-but-everything-goes-wrong-for-the-animations/32744/4 "2022-08-03T17:17:50Z")

</div>

I feel like my model which only contains one long animation of several is not suitable for gltf.  
Does that mean that I have to export my animations one by one in a separate file?

I saw this in SceneLoader:

```auto
BABYLON.SceneLoader.ImportAnimations('./animations/', 'walk.gltf', scene);
BABYLON.SceneLoader.ImportAnimations('./animations/', 'run.gltf', scene);

let walk = animationGroups[0];
let run = animationGroups[1];

```

Is this how I should do it?

---

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [August 3, 2022, 5:19pm UTC](https://forum.babylonjs.com/t/i-give-a-try-to-gltf-but-everything-goes-wrong-for-the-animations/32744/5 "2022-08-03T17:19:24Z")

</div>

Sorry I can’t create a PG. I don’t have a server to send my character file.

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [August 3, 2022, 5:20pm UTC](https://forum.babylonjs.com/t/i-give-a-try-to-gltf-but-everything-goes-wrong-for-the-animations/32744/6 "2022-08-03T17:20:48Z")

</div>

> [@Dad72](#):
>
> Is this how I should do it?

Probably not. glTF can have multiple animation clips in one asset. glTF Animation is equivalent to Babylon AnimationGroup.

> [@Dad72](#):
>
> I don’t have a server to send my character file.

One of these options? [Using External Assets In the Playground | Babylon.js Documentation (babylonjs.com)](https://doc.babylonjs.com/toolsAndResources/tools/playground/externalPGAssets)

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [August 3, 2022, 5:30pm UTC](https://forum.babylonjs.com/t/i-give-a-try-to-gltf-but-everything-goes-wrong-for-the-animations/32744/7 "2022-08-03T17:30:41Z")

</div>

@Dad72 How are you creating the glTF? Is it a custom exporter or some existing tool?

---

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [August 3, 2022, 5:49pm UTC](https://forum.babylonjs.com/t/i-give-a-try-to-gltf-but-everything-goes-wrong-for-the-animations/32744/8 "2022-08-03T17:49:54Z")

</div>

I made a PG using gitHub.

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

I just don’t know what to do compared to what I was doing before

---

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [August 3, 2022, 6:13pm UTC](https://forum.babylonjs.com/t/i-give-a-try-to-gltf-but-everything-goes-wrong-for-the-animations/32744/9 "2022-08-03T18:13:57Z")

</div>

I am using 3ds max 2017 to create and export the model

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [August 3, 2022, 6:16pm UTC](https://forum.babylonjs.com/t/i-give-a-try-to-gltf-but-everything-goes-wrong-for-the-animations/32744/10 "2022-08-03T18:16:30Z")

</div>

I see. The main issue is that all of the animation clips are in one animation in the glTF. This is not what you should do for glTF. glTF expects separate animation clips to be in separate glTF animations.

Here is a canonical example from the glTF sample models:  
[Babylon.js - Fox.gltf (babylonjs.com)](https://sandbox.babylonjs.com/?assetUrl=https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Fox/glTF/Fox.gltf)

There are 3 distinct animations in the model: Survey, Walk, Run. Each of these are in the glTF as separate glTF animations and are loaded as separate Babylon AnimationGroups.

Ideally, in your case, if you can do this on the export of the glTF, then you can simply use Babylon AnimationGroups to play the correct animation instead of trying to split the animation clips at runtime.

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [August 3, 2022, 6:17pm UTC](https://forum.babylonjs.com/t/i-give-a-try-to-gltf-but-everything-goes-wrong-for-the-animations/32744/11 "2022-08-03T18:17:55Z")

</div>

> [@Dad72](#):
>
> I am using 3ds max 2017 to create and export the model

I’m assuming you are using the Babylon glTF exporter? If so, there should be options to separate the full animation track into individual clips.

---

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [August 3, 2022, 6:22pm UTC](https://forum.babylonjs.com/t/i-give-a-try-to-gltf-but-everything-goes-wrong-for-the-animations/32744/12 "2022-08-03T18:22:06Z")

</div>

Oh, I see in 3ds max that I can create separate group animations with the right click.  
I will take a closer look at this. I think I figured out what was wrong.  
Thank you very much for your light bghgary

---

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [August 3, 2022, 7:00pm UTC](https://forum.babylonjs.com/t/i-give-a-try-to-gltf-but-everything-goes-wrong-for-the-animations/32744/13 "2022-08-03T19:00:05Z")

</div>

@bghgary I don’t know if I’m doing things right. But that didn’t change anything in my character file.

I started by doing this:

 ![2022-08-03 20_52_09-Greenshot](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/6/c/6c4c547b107cbeb8355f7e42d26d4f9ae907f35e.jpeg)

Then I export (here are the parameters that I check)

I specify that I tried to check (animation group) expor No-animated Object But that does not change anything, even seeing my character disappears in Babylon

 ![2022-08-03 20_53_12-Greenshot](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/a/7/a7d7e63386b4dcbbfefb8dd42617d84952c568fa.jpeg)

Results :  
I see that the animation groups are present in the log in the export

 ![2022-08-03 20_53_31-Greenshot](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/9/1/9109f2350405d95c0309a97e302a9bfcb5978a9a.jpeg)

But in Babylon I have nothing:

![2022-08-03 20_53_43-Greenshot](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/7/9/79457e90676cb1d390e24f353d90da10a3270611.jpeg)

Did I miss something?

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [August 3, 2022, 7:43pm UTC](https://forum.babylonjs.com/t/i-give-a-try-to-gltf-but-everything-goes-wrong-for-the-animations/32744/14 "2022-08-03T19:43:23Z")

</div>

Looks right. Can you send me the exported asset?

---

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [August 3, 2022, 8:34pm UTC](https://forum.babylonjs.com/t/i-give-a-try-to-gltf-but-everything-goes-wrong-for-the-animations/32744/15 "2022-08-03T20:34:52Z")

</div>

[edit] Ok, you had to select all the object and the skeleton included to add the group animations in 3ds max and add the viewport selection

So is has been exporting correctly now.  
I will be able to test the following.

thanks again

---

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [August 4, 2022, 12:09am UTC](https://forum.babylonjs.com/t/i-give-a-try-to-gltf-but-everything-goes-wrong-for-the-animations/32744/16 "2022-08-04T00:09:48Z")

</div>

Ok, everything works fine now for animations.

Thank you bghgary
