Problem with stopping fbx animation on time events when animation plays in reverse

Hi, I have a problem with stopping on time event when the animation plays in reverse: PlayCanvas | HTML5 Game Engine

Please hit the button on when the animation will stop and see that during playing reverse it ignores the time event.

Please help me with that.

Why does this happen? How to fix that? What I`m doing wrong here?

Loop is disabled. I haven’t set the time event to the first and last frame because it’s worse than that (I also don’t know why). So I`ve set time events just after the start and just before the end.

When it stops, it should give console.log info. During reverse it omits the time event near the begin of the timeline and there is no console.log info: ‘firststageanim, speed set to 1, animation stops’ what should show here.

Is it a known bug described here? Feedback Animstategraph: Reverse animation even when finished - #5 by dadiaar

What is the best solution to omit that / fix that (if it is the same thing)?

We have a ticket where events are not fired when animations are played backwards: Make anim events fire for reversed anims. · Issue #3808 · playcanvas/engine · GitHub

1 Like

Could you recommend me some temporary solution how to solve this?

Fbxanimation.prototype.update = function(dt) { 
    if( (this.entity.anim.baseLayer.activeStateCurrentTime  < 0)  || (this.entity.anim.baseLayer.activeStateCurrentTime  > 5) )  {
        this.entity.anim.speed = this.entity.anim.speed * (-1);

I’ve tried to do some time boundary but it also fails.

I’ve tried also to stop it at some specific time but it won`t play after that.

I would be grateful for any help.

Honestly, I can’t think of one beyond tracking the events yourself. ie checking if the activeStateCurrentTime goes pass a time boundary in the current frame and doing something when it does.

Or use a timer (Timers | Learn PlayCanvas) to fire the event after X time when you start playing the animation

1 Like

Is there any better solution?

I can’t stop and start it near begin and end of the animation because I won`t be able to start it again.
I can’t set it to an exact time because time counter skips some time and won’t stop if it won’t be a period of time.

What is the end result you are trying to get here? Do you just want to ping pong an animation?

I have three stages: begin (first frame), end (last frame) and middle-stage (middle frame).
I would like to have the animation stopped automatically on the first and last frame. It should wait until I press the first button to go back. The first button should switch the direction of animation and go from the first to the last frame and reverse;

The second button should do the same as the first does but additionally with a stop in the middle stage (I’m coding that second button on a different fork so it`s not visible yet); I suppose that for middle stage I need to do some event listener which will wait for animation goes to the middle frame. I’m not sure how should I prepare that eventlistener for time listening.

This is how I would do forward / back animation according to what you want here:

You can use that as a base and work out how best to listen/check if it’s hit the middle frame to stop the current state animation. Personally, I would do it as a state machine which checks with stage of the animation it’s in and what the user wants to do.

eg states of going from first frame to middle, middle to end frame, end frame to middle, middle to first, first frame to end, end to first

1 Like

Thanks for your help. In the meantime I`ve solved it in a more dirty way: