Jump to content

Play Animation after looped Animation


RelaX
 Share

Recommended Posts

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 null

scene.getAnimatableByTarget(shipMesh).onAnimationEnd = function(){    scene.beginAnimation(shipMesh, start, end);};

Problem:

it's never triggered

scene.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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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].currentFrame

Works, but I don't think I should access "_animations", is there another option?

Link to comment
Share on other sites

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*

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.

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...