How to Play multiple animation of a single object

Hii, I want to play animation on button click and the model has multiple amimation so how to play multiple animations of a single model

Hi,
You could have a look at animation groups.
but you don’t have to.
You can also use ‘animation blending’ , such as this in your single animations:

MyAnimation.enableBlending = true;

From your GUI (up or down pointer observable), you can launch both or multiple animations and with ‘enableBlending’ they will sync. But for more control, best is to use ‘animation groups’.
Hope this helps,

This is the project in which a am working on and i tried to play the multiple animations of the model it did no work
project link - https://playground.babylonjs.com/#Z6SWJU#227

Just to make this clear, are your animations in your imported from blender file. Because I cannot see any animations here?

yes the multiple animation is there there in the model as i have tested that in the sandbox by importing the model

Ok, thx. Unluckily, I have little experience with importing anims from blender so you should wait for someone else to answer. Meanwhile, you could already take a look at the console which throws an error likely to block all animations. It seems like ‘cannonImportResults’ is not defined.

Well thanks for the help but the error that is shown is an sucess error that is given every timr you import the model from the link

I don’t know about success errors (interpreted as an error that will show ‘on success’?), sounds a bit weird. To me, it rather shows that it is ‘not succesful’ and likely to break everything that’s coming next.
Again, you should wait for someone with more knowledge of this. Let me see if I can call in some people for you. May be @labris or @JCPalmer ?

There the error in your code, you try to call the variable which does not exist.
If you comment it and check for the scene.animationGroups, they are OK. You can turn on Play with Inspector and have a look. Seems that the model is done quite badly with animations…

Thx @labris,
I was pretty sure that would be the case but as I said, I’m far from being an expert on blender animations import :wink: However, this was not my question. You should have adressed your reply to @Ashish_Abhiwan . Hope this answer from labris will help you, Cheers,

Thanks

Thanks for the help, I want to know how will i play all the animations at a single time

Yes, well (no offense) but then apologies, I just had a chance to test labris fix and run some of your animation groups and… well, I believe some work would be needed to be performed on these.
First, I would start by grouping some of these meshes that obviously need to hold together (such as the side and side armature and many others. Set pivots for them and create less animations (for just opening a bag). There should be five or six (no more than that). One for each side and one for the closing/opening part. Animating all of these with or without groups will be both a nightmare and will likely create unexpected results. Just saying (again, no offense). My opinion only.

You cannot play all animations groups at once; you may play one animation group with all animations in it.

    scene.animationGroups.forEach((g)=>{
        g.stop()
    })

    let someAnim = scene.animationGroups[2]
    someAnim.play()
    someAnim.loopAnimation = true

As I already wrote, animations in your model are badly done and actually are broken. This relates to the model, not to Babylon. Please read more documentation :slight_smile:

1 Like

Thanks for the suggestion i will take a look in that while making the animation

Thanks for the help

1 Like

I want to play the animation on button click but the animation keeps on playing and i want that the animation should be played one time only.@labris

Change it to false

@labris Well I want that animation to be played only after i click the button

So you should not call someAnim.play() and rather call it in the button click callback code

1 Like