Animation Groups Not working

I have a animated model, and I took my code from https://www.babylonjs-playground.com/#BCU1XR#0

But when I click in the button Its dosent work.

But if I inspect on console I see the animation

When I run “skeleton.getAnimationRange(“yumeko|idle a”)” it return undefined

I try also direct from console and nothing

It just play the frist animation always

The AnimationGroups are not the same as skeleton.animations.

An AnimationGroup allows you to link together animations and meshes and play them, pause them and stop them as a group. (Group Animations - Babylon.js Documentation)

So in your case, you should just need:

scene.animationGroup[1].play(true)
1 Like

yes, works thanks.

and Its

scene.animationGroups[2].play(true)

How I do I go from scene.animationGroups[1].play(true) to scene.animationGroups[2].play(true)

What do you mean? Like you need to stop the first and then call the second?

Something like a smooth animation exchange

This is something you may be interested by:
https://doc.babylonjs.com/babylon101/animations#animation-blending

The idea is to flag all animations of an AnimationGroup with blending like that:

scene.animationPropertiesOverride = new BABYLON.AnimationPropertiesOverride();
scene.animationPropertiesOverride.enableBlending = true;

See #line 61: https://www.babylonjs-playground.com/#7A9BIM#10

3 Likes

wow! my animation finally plays!
but i need to clone the player. there’s 2 players. i can’t figure out how to animate the 2nd player. why is this animation stuff such a messy pile of trash?

What do you mean?

It is not a messy pile of crap if:

  • you read the documentation
  • you tend to be respectful
  • you understand that gltf has a way to deal with animations which is different than the initial one from bjs (where animations where hosted by the entities)

Again please remain respectful

2 completely separate methods of animation, which wasn’t made clear anywhere, causing me to not be able to find my loaded animations for days. (animationGroup vs skeleton)

animationGroups loaded into an array in global scope, instead of loaded onto my model. if i load multiple models how do i even keep track of what animations are what. the documentation is like ad-hoc scene.animationGroups[2].play() lol. there’s race conditions based on what models load in first.

i have models and animations ready to go (from mixamo), but i can’t load them in without first booting up blender, importing them into there. and following some cryptic nonsense steps to export a proper model with multiple animations. (even the official documentation says you have to DELETE your other animations, then select them from an animation dropdown (they still exist there for some reason???)). adding a new animation to your model later is like impossible, gotta redo the whole thing again and hope it works. lots of manual nonsense work. took me like 10 attempts until i got a working model

the babylon youtube video " Demystifying Animation Groups" is like 100 lines of ad-hoc code just to copy a simple model with animations. and idk how to translate that to my project because my mixamo animations have lots of data in them that idk how to detach then reattach

i could go on forever. it’s the biggest mess i’ve seen in my life. i’m complaining about 3d animations in general btw, not necessarily babylon, no reason to get offended.

i’m new to 3d, so idk who’s fault this all is. i just know this modern way of handling animations is archaic and won’t last long

Because animation groups can target multiple targets (not just your mesh)

I’m sure @PirateJC can help you if you start to be respectful

in theory. but in practice i’ve been trying to do that for a day. doesn’t work because it gets loaded in tied to your mesh. i’d have to do the 100 lines of detach/reattach code that i don’t understand, right? currently i’m just importing the model multiple times (multiple network requests) as a temporary solution

Hey @farzher I definitely echo what @Deltakosh is saying here.

This is a friendly community and we’re more than happy to help everyone learn, but it all starts with calm mutual respect.

You’re making it very evident that you’re frustrated and we’re sorry to hear that, but let’s remain respectful please.

How can we help? I’m very bias on the subject, but I do think the Demystifying Animation Groups video does a decent job of explaining how animation systems in Babylon.js work.

Here’s the high level gist:

“Animation data” can be used to create an “Animation” in Babylon. For example, let’s say you have some generic animation data like (int 0 at frame 0 and int 5 at frame 30).

You take that data and create a Babylon “Animation” with it. In Babylon an “Animation” is independent of an object because we want you to be able to apply that “Animation” to any object property in the scene. So you could take your int 0 at frame 0 and int 5 at frame 30 and apply that to anything from a box position, to camera clipping planes.

So a generic “Animation” can be applied to just about anything in Babylon.

To apply an animation to something you create what we call a “Targeted Animation.” This is the “Animation” that we created earlier, but applied to a specific target. For example the box position or the camera clipping plane would be the target. With a “Targeted Animation” you now have an “Animation” that affects a specific “target.”

“Animation Groups” are groupings of 1 or more “Targeted Animations”. Let’s say you want to take our int 0 at frame zero and int 5 at frame 30 “Animation” and apply that to both a cube position AND a camera clipping plane…and play them both at the exact same time. You would take that animation, create 2 different “Targeted Animations,” and then put them inside of an “Animation Group.” The animation group then has some nice methods that you can use to control all of the “Targeted Animations” inside of it at the same time. so “Animation Group.play()” will play all of the Targeted Animations together at once.

I’ll refer you back to this specific part of the video that touches on this subject: https://youtu.be/BSqxoQ-at24?t=441

Now things get SLIGHTLY more complicated when you bring in a 3D object that has animation data in it that comes from another piece of software like Blender. Let’s say you have a cube that rotates around Z in Blender. If you export that object out of Blender and include the animations, Babylon will load that object with an Animation group already set up for you that has the Targeted Animation in it. So a lot of heavy lifting is already done for you.

Here’s the cool thing. Because animations are separate entities from objects, you can very easily extract that animation data and use it elsewhere in the scene.

It takes a little getting used to understand how it’s set up, but once you understand the hierarchy hopefully you can understand the power of what’s possible with the animation system.

I hope this helps make things a little more clear.

Cheers!

2 Likes

If the file format is gltf

1 Like

Also, if you have your mesh loaded, you simply clone the mesh and the skeleton and you are done:
Animation bug | Babylon.js Playground (babylonjs-playground.com)

Look at the rabbits here:
image

With different animations:
image

1 Like

uh oh, sounds like even you’re confused about animations. that doesn’t work because that only works for skeleton based animations. a completely separate animation system than animationGroups

Well I would be confused about something I created then:) which would be sad and depressing.

The one confused is you:You are mixing animations and skeletons.

Skeletons are ways to bend a mesh.

They can be animated but they are not animations

Animations are the way you can change a given property along a specific duration( you can animate smithing in babylonjs)
Animation groups are… groups of animations

Based on the tool and file format you are using you can either get animations stored only on the animated entity or on both the entity and a root animation group.

But based on your way of communicating It is really tough to help you so I suggest you open a new post where you clearly state what you want (as the entirety of people who tried to help you don’t understand what you need)

Make sure to add a repro in the playground of what you have so far

(By the way, you are really close to join my ignore list and I can tell you this is an achievement as the list is empty so far)

Up to you now…