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.
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.
Hi Sir, I completely understand all the above answers. But I have a question here:
How can I attach an AnimationEvent to animation if the animation is LOOPING
I expect I can console.log message every time the animation arrives at that progress point when looping.
I expect it console.log(“Yeah!”) every at 10% progress when looping
Currently it just console.log once
Thanks in advance for any hint to solve the problem!
Thanks, Deltakosh! I keep on finding these bits of wisdom tucked away in old posts. . I was perplexed that I couldn’t get an event to trigger until I saw your post and placed the animation after the event-setting.
It’s been a few months since you posted (so you probably resolved this already), but I thought I’d try to make Events repeat during the “Dude’s” looped walk cycle. It’s a pretty rough and messy attempt, so the Events go out of sync after a while–but they do repeat! The basic idea behind it is to use an event (event3, in this case) at the end of each walk cycle that restarts the animation. I used two versions of the same walk cycle and the switching of a number variable to try to alleviate the events-going-out-of-sync problem, but it didn’t work. Anyway, here’s a PG, for what it’s worth:
Edit: the lights dimming and brightening (the events I used) went out of sync in exactly the same way no matter how I revised the code–and they repeatedly got back in sync again for a short while, which makes me wonder if the problem is due to lag caused by the light increasing in intensity? Maybe it’s slower than the dimming of the light? Not sure if that makes logical sense…
Hello! Instead of attaching the events to the bones, the way I would do it is by creating a “dummy” animation to handle events, and adding everything to an AnimationGroup. This way, I wouldn’t have to worry about choosing a bone to add an animation to, or anything else, and it loops nicely this way: AnimationEvent and skeleton animation | Babylon.js Playground (babylonjs.com).