Get Animation from Animation Group

I’m trying to test out a few animation features like animation events and grouping animations using rigged characters but having trouble understanding how to reference the animation data properly. I’ve provided a playground here: https://playground.babylonjs.com/#YAL1RN#26 that includes a rigged character with two separate animations.

The animations were organized using the Non-Linear Animation tool within Blender. I’d like to be able to control a few rigged characters in a scene using an animation group to start/stop their animations based on events within the game. For events this would involve having a character playing an attack animation and the enemy playing their death animation at a specific point using animation events.

Can anyone explain how I can reference the individual animations of a character like this so that they can be used with animation events and grouping?

Hello! Sorry, I don’t think I fully understood the question :sweat_smile: You want to be able to select the animations as “death” or “attack” instead of indexing on the animation arrays? If so, you can use getAnimationGroupByName on the scene. This is your playground using these functions: glTF Loader Demo | Babylon.js Playground (babylonjs.com)

1 Like

Let me clarify, how would I use animation events with the rigged character in the playground? Let’s say at frame 60 within the “scream” animation I would want to call a function. Here is an updated playground of my attempt at creating an event and trying to display a console message at frame 60:

It seems like I might have the animation of ‘scream’ that I can add the event to, but nothing appears in the console. So I’m not sure if the way of referencing this animation is incorrect, or if there’s an issue with how the event is created/added.

Is there no way to use animation events with imported animations like the one in my playground above? I know I can time it myself, but I’d like to use the built-in animation events if possible.

It works if you start the animation after the event is added like below. :slight_smile:

1 Like

Well, that was simple enough, thank you!