AnimationEvent on skeletal animation

I would like to attach an AnimationEvent to a skeletal animation.

Following this example from the documentation:

From the API I understand skeleton has the property animations, but when I try to to print, it throws an error. AnimationEvent - Babylon.js Documentation

What am I doing wrong? :slight_smile:
Thanks in advance for any hint to solve the problem!

Animations in your case are not on the skeleton itself but on each individual bone:

1 Like

Thanks for you help @Deltakosh
I hope, I’m not stupid again but I’m kinda expecting a console.log ‘Yeah’, which I don’t see. ˆˆ …

1 Like

No worries

What I was actually trying to say was:

I can’t see the console.log in your playground. So I assume that the event is not raised. Though, I think it’s not working yet :relaxed:

Or did I miss something? @Deltakosh

haha sorry :slight_smile:
You just need to start animations AFTER setting the events:

1 Like

Reading up on this thread. Also trying to attach an AnimationEvent to a frame number. For example: : At frame number 1.3, console.log(“hello world.”).

Feel like I’ve been through every conceivable combination of object and array in the console, but no luck being able to attach an event to anything. Finally found an object that would accept addEvent without erroring out… but doesn’t seem to do anything. How the heck do you grab a handler to an animation group? Seems like it’s all there in inspector… but can’t figure out how to grab it.

Hey @bigrig, I adjusted your playground. I think it should work now:

I think, the problem was, that the animation duration was frame: 4.5 but your event was attached to frame: 10.

Not 100% sure – maybe the pro’s know more about that – But I think glTF and glb’s don’t work with frames anymore but with actual time. That’s why framesPerSecond is 1 in your file but your animation plays fluidly.

Ohmygosh. I was so focused on finding the path to animation that i didn’t notice that param! Thank you thank you!

Yes, strange about FPS. Also the structure of the exported GLB seems kind of a mess. There’s a couple replicated skeletons within armatures, all those keyframes, and an extraneous camera/light. I figure its related to my convoluted pipeline (FBX->Mixamo->GLB->Blender->GLB). But I’m not complaining, b/c with this frame event, everything in my game is now working! Awesome.