Jump to content

OnAnimationEnd


petemac
 Share

Recommended Posts

Hello

 

Everytime I try to do something at the end of my animation with onAnimationEnd, it happens at the start of my animation or it doesnt work at all.

I try to alert at the end of my animation in this example below and I get the alert as soon as the animtion starts playing instead.

var ani = 0;var sceneready = false;var playable = false;BABYLON.SceneLoader.ImportMesh("", "firstpersongame/", "human25.babylon", scene, function (newMeshes, skeleton) { });scene.executeWhenReady(function (){sceneready = true;});function theendani(){ani = 1;}scene.registerBeforeRender(function () {if(sceneready){myMesh = scene.getMeshByName("HumanMale");myMesh.position = new BABYLON.Vector3(0, 1, 0);sceneready = false;playable = true;}if(playable){if(ani == 0){//All of these play the animation once but do not trigger the ani = 1 at the end of the animation//For some reason I am getting the alert right when the animation starts//I realize they are commented out I tried each of these individually:ani = 5; // So it doesnt call beginanimation again.//scene.beginAnimation(myMesh.skeleton, 85, 105, false, 1.0, ani = 1);//scene.beginAnimation(myMesh.skeleton, 85, 105, false, 1.0, ani = false);//scene.beginAnimation(myMesh.skeleton, 85, 105, false, 1.0, theendani());//scene.beginAnimation(myMesh.skeleton, 85, 105, false, 1.0, onAnimationEnd(){ani = 1;});//scene.beginAnimation(myMesh.skeleton, 85, 105, false, 1.0, onAnimationEnd(ani = 1));//ive also tried setting the animation to loop = true and it still triggers onanimationend at the start of my animation and then just loops the animation}if(ani == 1){//scene.stopAnimation(myMesh.skeleton);//scene.beginAnimation(myMesh.skeleton, 1, 85, false, 1.0);alert("end");ani = 2;}}}

Also how do you tell what frame the animation is on? Custom time tracker?

For example if I wanted onAnimationEnd to be called at frame 99 of my animation.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...