How to toggle the animationGroup

Hi, guys:
I want use one button to pause/restart the animationGroup.
But I found animationGroup.isStart/isPlaying is not updated when restart it.
So I can’t how whether the animationGroup is paused or not. How cound I do?

demo to check:
AnimationGroup demo | Babylon.js Playground (babylonjs-playground.com)

  1. click ‘Play’ btn to start animationGroup
  2. click ‘Pause’ btn to pause it, the isStarted is still true, isPlaying changed to false
  3. click ‘Pause’ btn again to restart it, but the isPlaying is still false
    so I can’t use isStarted/isPlaying to get the animation running state

Thanks.

Hello @jacksonyin , how are you doing?

I think this might be a bug in the API. I’m adding @RaananW just to be sure. I will open a ticket for it in the Babylon Github. As a work around I think you could add a AnimationGroup.play call after your restart call. This should flag the AnimationGroup as playing = true.

Here is a working example:

AnimationGroup demo | Babylon.js Playground (babylonjs-playground.com)

Link to Github issue: AnimationGroup.restart() does not set isPlaying to true · Issue #15416 · BabylonJS/Babylon.js (github.com)

This seems to be a bug and needs to be fixed. I’ll submit a quick fix soon

EDIT - move isPaused to restart by RaananW · Pull Request #15417 · BabylonJS/Babylon.js (github.com)

thanks for your quick fix. Looking forward to the new version :slight_smile:

1 Like