Asynchronous Triggered Animations

https://www.babylonjs-playground.com/#9WUJN#211

Hello, I’m wondering on the best way to start an animation that is asynchronously triggered by user actions. Playground is a rough mock-up of the concept-- basically the user will interact with something in the HTML (not the canvas!) and trigger a flag that should cause the animation to run on the next frame.

Oddly, using BABYLON.Animation.CreateAndStartAnimation as opposed to scene.beginDirectAnimation appears to work. However, I would prefer to use the later as it has more flexibility in how it operates (and I can define the animation elsewhere) if possible. Any ideas where I’m going wrong?

https://www.babylonjs-playground.com/#9WUJN#212 --> onBeforeAnimationsObservable version

Hey
the scene.beginDirectAnimation expects an array of animations: https://www.babylonjs-playground.com/#9WUJN#213

1 Like

Ah, indeed it does. Thanks for the help!

1 Like