How to use onAnimationEnd

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

1 Like

Hi @mecanicus <- cool handle! :slight_smile:

Here is how we use it in a jump animation…

        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
                }
            }
        }
2 Likes

Thank you very much it works

1 Like