React to a certain frame being played in an animation

I want to react to a certain moment in an animation. For example, when I play a “swing sword” animation there is a certain moment in the sword swing where I want to play a hit recovery animation on the target and lower their HP.

Blender has the concept of animation frame markers which I thought would be a good way to handle this. I could label one frame as the “deliver hit” frame. The problem is I don’t think .gltf/.glb has the concept of animation frame markers.

I could take note of the frame number for each of my animation that I want to react to and use a Record<AnimationName, FrameNumber> to store the frame numbers I want to react to, but this requires that I maintain that HashMap separately from my actual animations.

Is there a more accepted solution to this?

https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#attach-events-to-animations

1 Like

Perfect, thank you!