# How to use onAnimationEnd

**URL:** <https://forum.babylonjs.com/t/how-to-use-onanimationend/2731>\
**Category:** Questions\
**Created:** [April 23, 2019, 3:51pm UTC](https://forum.babylonjs.com/t/how-to-use-onanimationend/2731 "2019-04-23T15:51:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mecanicus](https://avatars.discourse-cdn.com/v4/letter/m/ac8455/32.png) [@mecanicus](https://forum.babylonjs.com/u/mecanicus)\
**Post date:** [April 23, 2019, 3:51pm UTC](https://forum.babylonjs.com/t/how-to-use-onanimationend/2731/1 "2019-04-23T15:51:45Z")

</div>

Hi, I’m using the following code to create an animation: BABYLON.Animation.CreateAndStartAnimation (‘at7’, needle, ‘rotation.z’, speed, 300, needle.rotation.z, rotationAguilla, 0, ease) ;. I want to detect the end of the animation using the onAnimationEnd instruction, which is the correct syntax for that. Thank you

---

<div class="post-metadata">

**Author:** ![aFalcon](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/afalcon/32/7015_2.png) [@aFalcon](https://forum.babylonjs.com/u/aFalcon)\
**Post date:** [April 23, 2019, 4:09pm UTC](https://forum.babylonjs.com/t/how-to-use-onanimationend/2731/2 "2019-04-23T16:09:24Z")

</div>

Hi @mecanicus \<- cool handle! 🙂

Here is how we use it in a jump animation…

```auto
        animo = nx.scene.beginAnimation(nx.aSkeleton[0], 20, 25, false, 1.0); //compress
        animo.onAnimationEnd = function (){
            var jmp1 = nx.scene.beginAnimation(nx.aSkeleton[0], 25, 35, false, 1.0); //jump apex
            jmp1.onAnimationEnd = function(){
                nx.anmz.jump.jumpMode = 0;
                var jmp2 = nx.scene.beginAnimation(nx.aSkeleton[0], 35, 50, false, 1.0); //landing
                jmp2.onAnimationEnd = function(){
                    nx.scene.beginAnimation(nx.aSkeleton[0], 80, 140, true, 1.0); //idle
                }
            }
        }

```

---

<div class="post-metadata">

**Author:** ![mecanicus](https://avatars.discourse-cdn.com/v4/letter/m/ac8455/32.png) [@mecanicus](https://forum.babylonjs.com/u/mecanicus)\
**Post date:** [April 23, 2019, 5:51pm UTC](https://forum.babylonjs.com/t/how-to-use-onanimationend/2731/3 "2019-04-23T17:51:42Z")

</div>

Thank you very much it works
