Is there a way to get a callback when the AnimStateGraph is done playing the animation of the current state?
I could think of using Animation Events and adding them to the animations in my state graph at runtime, but I’m not sure how to do that. Maybe there is some easier solution.
Sorry maybe i should have specified i want to do that at runtime. As i have quite a bunch of animations and i don’t want to manually do this for every animation.
You can add the events at runtime on the anim asset resource:
const walkTrack = assets.walkAnim.resource.animations[0].resource;
// Add two anim events to the walk animation, one for each foot step. These events should occur just as each foot touches the ground
walkTrack.events = new pc.AnimEvents([
{
time: walkTrack.duration * 0.1,
name: 'foot_step',
bone: 'R_foot0002_bind_JNT'
},
{
time: walkTrack.duration * 0.6,
name: 'foot_step',
bone: 'L_foot0002_bind_JNT'
}
]);
Bear/Bare in mind that animationAssets is not public API and there isn’t a public API to get the assigned assets to the component so that may change in the feature.