RelaX Posted July 15, 2015 Share Posted July 15, 2015 Hi,what's the best way to begin an animation after a looped animation finished the actual loop? My attempts were:var animatable = new BABYLON.Animatable(scene, shipMesh, start, end);var animation = animatable.getAnimationByTargetProperty('position.z');scene.getAnimatableByTarget(shipMesh).appendAnimations(shipMesh, [animation]);Problem:TypeError: r is nullscene.getAnimatableByTarget(shipMesh).onAnimationEnd = function(){ scene.beginAnimation(shipMesh, start, end);};Problem:it's never triggeredscene.getAnimatableByTarget(shipMesh).loopAnimation = false;scene.getAnimatableByTarget(shipMesh).onAnimationEnd = function () { scene.beginAnimation(shipMesh, start, end);};Problem:Setting loopAnimation to false kills the actual loop. I guess there is an easy way to do what I want, but I can't find it. brgds Quote Link to comment Share on other sites More sharing options...
Wingnut Posted July 15, 2015 Share Posted July 15, 2015 Hi RelaX, welcome to the forum, good to have you here. I did SOME talk about your animation issue here: http://www.html5gamedevs.com/topic/2571-the-wingnut-chronicles/page-31#entry89280 You did something enjoyable and entertaining, and you didn't even know you did it. There is a demo there... and some light discussion about animatables. AND, 6-10 posts previous to that one... talk LOTS about animations. Maybe that will help you enough to get you rolling. Good luck and keep us posted, please. Again, welcome aboard! Quote Link to comment Share on other sites More sharing options...
amorgan Posted July 16, 2015 Share Posted July 16, 2015 relaX, would you be able to duplicate this problem using the playground? babylonjs-playground.com Unless Wingnut was able to nudge you in the right direction -amorgan Wingnut 1 Quote Link to comment Share on other sites More sharing options...
RelaX Posted July 16, 2015 Author Share Posted July 16, 2015 I created the animatable because I tried to get an animation object for appendAnimations(). Well, I think my best option would be something like that:var anim = scene.getAnimatableByTarget(shipMesh);var currentFrame = shipMesh.animations[0].currentFrame;var currentEnd = anim.toFrame;scene.beginAnimation(shipMesh, currentFrame, currentEnd, false, 1, function () { scene.beginAnimation(shipMesh, start, end, false);});Edit:Hm, shipMesh.animations ist empty, where can I find the currentFrame? Edit:var currentFrame = anim._animations[0].currentFrameWorks, but I don't think I should access "_animations", is there another option? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted July 16, 2015 Share Posted July 16, 2015 Hi again, RX! Looks like you're doing fine. I have never used appendAnimation... so thanks for the information. Um... somewhere, you MADE the animation object...var myAnim = new BABYLON.Animation("at5", "rotation.z", 30, BABYLON.Animation.ANIMATIONTYPE_FLOAT, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);You have a line like that, somewhere, correct? You have never pasted a line like that... to us. myAnim.currentFrame is then easy to access, yes? Have you pushed myAnim into shipMesh.animations? *shrug* Quote Link to comment Share on other sites More sharing options...
RelaX Posted July 16, 2015 Author Share Posted July 16, 2015 I export the scene from max and use the auto-animate function in the exporter for the idle animation. ImportMesh does everything else Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted July 16, 2015 Share Posted July 16, 2015 Interesting, interesting, and... um... interesting! You are filling-in gaps in my study of animations. Thanks! Nothing lands in shipMesh.animations after the load, huh? Weird. (new learning for me) Hey, is there anything in your scene._activeAnimatables array... after scene.isReady or somewhere near that time? Does the idle animation land there? (thanks) Quote Link to comment Share on other sites More sharing options...
RelaX Posted July 17, 2015 Author Share Posted July 17, 2015 There are some animations, don't know which ones, but I guess the idle animations. We changed our animations from bones+skin to a direct animation on the object. And now shipMesh.animations has 2 objects, one for the position and one for the rotation. I guess I don't have to access _animations anymore. Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.