Play animation group from one frame to another?

Hello, is it possible play an animation group from one frame to another?

In my scene I have a camera and camera target that animate from left to right. The camera needs to pause at certain points along the scene.

I want to trigger the camera to move and then stop at the intervals such that I can say play from frame 0 to frame 200 then stop. Then when a button is clicked go from 200 to 400. So and so forth. And the same for going backwards (frame 400 to 200).

Any help on this would be greatly appreicated.

animation.start(true, 1.0, animation.from, animation.to, false);

You can set your keyframe in animation.from and animation.to

animation.start(true, 1.0, 200, 400, false);

Hope it helps

2 Likes

Is there anyway to add a callback so when the group stops, some code is executed.

I tried adding to the animationGroupPauseObservable and the animationGroupStopObservable with no sucess

Probably in this case you need onAnimationGroupEndObservable ?
Example from documentation - https://playground.babylonjs.com/#CBGEQX#4

Turns out I was just being dumb. I was calling the wrong method lol

Thanks for your help!

2 Likes

Also I would recommend you to take a look at the AnimationGroup API.
It´s very clear

3 Likes