# AnimationGroup questions

**URL:** <https://forum.babylonjs.com/t/animationgroup-questions/2348>\
**Category:** Questions\
**Created:** [April 3, 2019, 9:31pm UTC](https://forum.babylonjs.com/t/animationgroup-questions/2348 "2019-04-03T21:31:05Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [April 3, 2019, 9:31pm UTC](https://forum.babylonjs.com/t/animationgroup-questions/2348/1 "2019-04-03T21:31:05Z")

</div>

Hi.  
I have few questions related to animationGroup.  
Curently I’m working on a demo with a character which should have morphtargets, and when I searched for samples or doc I saw that we don;t have too many examples related  
to this, and I want to change this,… with little help. 🙂 So

1. [https://www.babylonjs-playground.com/#DS22WT#4](https://www.babylonjs-playground.com/#DS22WT#4) - line20 Param is false, so it’s expecting to stop on finish or?
2. If uncomment line 13,14,15 it’ll stop on finish. Or it is a bug or i understood wrong.
3. Is there a way to reverse animation, like on beginAnimation function where if I put speedRatio -1 the the animation reverse (If i remember corect). Here doesn’t work.
4. If I understood well, on export, morphtargets are exported as animationGroup, and in scene I have to play with animationGroup if I want to simulate somehow morphs. Do I understood well?
5. If answer of question above is yes, then how I can do this?  
In the same playground I tried something, line 52,53, but I’m not sure that this is ok. I think this is not working as expected.

I think just these for now.  
I need a break 😋

---

<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:** [April 4, 2019, 1:45am UTC](https://forum.babylonjs.com/t/animationgroup-questions/2348/2 "2019-04-04T01:45:07Z")

</div>

Ok let’s go!

1. This is because the animation is already running. You need to first stop it and then restart it with your loop = false parameter: [https://www.babylonjs-playground.com/#DS22WT#5](https://www.babylonjs-playground.com/#DS22WT#5)
2. Nope this is expected as thanks to this line no animation will be started by default and thus 1. will really start the animation
3. Yes you can: [https://www.babylonjs-playground.com/#DS22WT#6](https://www.babylonjs-playground.com/#DS22WT#6) 😃
4. For gltf yes (pinging @bghgary for confirmation)
5. Waiting for gary’s confirmation first 🙂

---

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [April 4, 2019, 6:56am UTC](https://forum.babylonjs.com/t/animationgroup-questions/2348/3 "2019-04-04T06:56:55Z")

</div>

Hey @Deltakosh, thanks for tips.  
I’m trying to summarize. And maybe at the end we’ll add this info to doc.  
Please corect me if I’m wrong.

AnimationGroup for gltf/glb files

1. The only import function which has ‘directly’ acces to animationGroup from your gltf/glb file is importMesh, where the 4th param is animationGroup. For all other functions like Load, Apend, or if we are using taskManager, we can acces it only with scene.animationGroup, or, with scene.getAnimationGroupByName

2. By default animationGroup is playing. So when we import a model its animations is already playing. We can avoid this using

3. We can reverse an animation from animationGroup with speedRatio -1, but we need to specify from and to frames (I tried without 🙂, because of this it didn’t work)

4. Morptargets are exported as animationGroup, so if we want to play with morph influence in our scene, we have to play with animationGroup to simulate interaction with morph.  
[https://www.babylonjs-playground.com/#DS22WT#7](https://www.babylonjs-playground.com/#DS22WT#7)

5. How to add events to animationGroup. Is required to add the even to each animatable from group, but do the action from event only one time, not for all animatable.  
[https://www.babylonjs-playground.com/#DS22WT#8](https://www.babylonjs-playground.com/#DS22WT#8)

To add.  
clone - [How to clone a GLB model and play seperate animation on each clone?](https://forum.babylonjs.com/t/how-to-clone-a-glb-model-and-play-seperate-animation-on-each-clone/2351/8), - [https://github.com/BabylonJS/Babylon.js/issues/5423](https://github.com/BabylonJS/Babylon.js/issues/5423)

---

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [April 4, 2019, 7:01am UTC](https://forum.babylonjs.com/t/animationgroup-questions/2348/4 "2019-04-04T07:01:13Z")

</div>

One more question  
6. I saw files which has skeleton and animationGroup too. (I’m talking only about gltf/glb files)  
Are there situations when we can use animations from skeleton instead of animationGroup? Or for these extensions animationGroup is like a ‘must’, and it is not recomanded to use skeleton?

---

<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:** [April 4, 2019, 1:22pm UTC](https://forum.babylonjs.com/t/animationgroup-questions/2348/5 "2019-04-04T13:22:02Z")

</div>

This is correct!

---

<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:** [April 4, 2019, 1:22pm UTC](https://forum.babylonjs.com/t/animationgroup-questions/2348/6 "2019-04-04T13:22:46Z")

</div>

1. Animationgroups are helper and you can decide to use animations directly if you want. Up to you

---

<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:** [April 4, 2019, 5:26pm UTC](https://forum.babylonjs.com/t/animationgroup-questions/2348/7 "2019-04-04T17:26:27Z")

</div>

> [@MarianG](#):
>
> 1. If I understood well, on export, morphtargets are exported as animationGroup, and in scene I have to play with animationGroup if I want to simulate somehow morphs. Do I understood well?

I’m not totally sure I understand the question, but if you mean morph targets are animated by animations which are grouped in animation groups, then yes. Each part can also be manipulated individually.

---

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [April 4, 2019, 5:33pm UTC](https://forum.babylonjs.com/t/animationgroup-questions/2348/8 "2019-04-04T17:33:52Z")

</div>

Hey @bghgary, this is clear now.

It remains the 5th question, related to this.  
I want to manipulate them somehow, as example [here](https://www.babylonjs-playground.com/#HPV2TZ#8) I can use a slider and play with morph influence, but  
with animationGroup how to do this?  
I tried with animation weight but seems is not working very well.

Thanks for your time 😉

---

<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:** [April 4, 2019, 6:12pm UTC](https://forum.babylonjs.com/t/animationgroup-questions/2348/9 "2019-04-04T18:12:15Z")

</div>

Perhaps you are looking for the [goToFrame](https://doc.babylonjs.com/api/classes/babylon.animationgroup#gotoframe) function?

---

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [April 4, 2019, 6:27pm UTC](https://forum.babylonjs.com/t/animationgroup-questions/2348/10 "2019-04-04T18:27:23Z")

</div>

Oki, I’ll try it and let you know.

---

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [April 5, 2019, 10:06am UTC](https://forum.babylonjs.com/t/animationgroup-questions/2348/11 "2019-04-05T10:06:00Z")

</div>

Yeeeees. This was  
[https://www.babylonjs-playground.com/#DS22WT#7](https://www.babylonjs-playground.com/#DS22WT#7)  
Thanks. I’ll try with a mesh with multiple morphtargets.

---

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [April 16, 2019, 6:46am UTC](https://forum.babylonjs.com/t/animationgroup-questions/2348/12 "2019-04-16T06:46:20Z")

</div>

One more question here 🙂

This is the best way to add events to animationGroup?  
[https://www.babylonjs-playground.com/#DS22WT#8](https://www.babylonjs-playground.com/#DS22WT#8)  
Or there is a better way?  
I’m asking because this looks a little bit too complicate, and ‘heavy’ if I have more than 400 animatable in the animationGroup. Thanks 😉

---

<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:** [April 16, 2019, 1:58pm UTC](https://forum.babylonjs.com/t/animationgroup-questions/2348/13 "2019-04-16T13:58:27Z")

</div>

We could simplify it with a function at Animationgroup level but ultimately it will do exactly that

---

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [April 16, 2019, 3:09pm UTC](https://forum.babylonjs.com/t/animationgroup-questions/2348/14 "2019-04-16T15:09:53Z")

</div>

Great! Thanks 💪
