AB95

Restart a finishing animation

5 posts in this topic

Hi everyone,

there might be a way of doing this but I must be missing something...

I have a scene which consists of different meshes having different animations, all of the animation only run once.

Basically, I would like to be able to "reload" the scene without actually reloading it, which I try to reset all the meshes' animations by pausing all unfinished meshes' animatable, set their animation's frame back to zero, and restart each of the animatable again.

This method work when all of the animatables in scene have not reached their last frame. It won't work on those animatable who had reached its last frame, which their frame will be set to zero, but not able to be restarted.

A simplified scene that showing my approach, as you will see the restart button doesn't work when the animation has reached its last frame.

http://www.babylonjs-playground.com/#OQENJ

Any help would be appreciated, thank you!

Share this post


Link to post
Share on other sites

Hi @aWeirdo and @JohnK

Thanks for both of your quick response! 

JohnK method works for me -- only if my issue is within the playground scene, the thing is, sry for the simplified scene, I realise I should have pointed out some part that make me resist in using scene.beginAnimation, the reason is that I had another animation within the callback of the first animatable:

http://www.babylonjs-playground.com/#OQENJ#5

which using scene.beginAnimationI() will cause the animatable within the first animatable's callback being called without the first animatable completes its animation (you should be able to observe the second animatable start before the first animatable finish, by pressing the restart button before the box finish its animation).

 I try to I explain my problem as clear as possible, thanks for the help!

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.