Hi,
I’m trying to reverse an already running animation, but the onAnimationEnd event doesn’t get triggered in this case.
What I’m basically trying to do is add a button with an animation (move in with alpha fade in effect from side). This button can be clicked during the animation, and the animation should reverse at the current frame. But I also need to know when the animation is done.
My idea was to simply set the speedRatio of the animatable to -1, which seems to work, but the event isn’t triggered anymore in this case.
Here is a simple playground example: https://playground.babylonjs.com/ts.html#3CARG0
At frame 120 the animation is reversed using an animation event. If you remove the line “animation.addEvent(animationEvent);”, the text in the center shows “Animation finished”.
Is this a bug, or do I have to do something else to accomplish this?
About your issue, i don’t know if is a bug, or not, but I’ll tell you what are you doing in your playground
So you set first keyframe visibility to 0 and last keyframe to 1, but meanwhile in the midle of animation you reverse it, this means from 0.5 you go back to 0. I think because of this the end event is never triggered, the animation don’t meet the conditions to be completed
This won’t work unfortunately, because the user can click the button at any time during the animation, so the animation has to be reversable at any frame, the center used in playground was just an example. And it can also just play normally until it’s finished at the last frame.