Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweens are not working when playcanvas is in background #36

Open
Arjunxxxl opened this issue Jan 2, 2023 · 1 comment
Open

Tweens are not working when playcanvas is in background #36

Arjunxxxl opened this issue Jan 2, 2023 · 1 comment
Labels

Comments

@Arjunxxxl
Copy link

Arjunxxxl commented Jan 2, 2023

We are making a game in which we are updating entity's position and rotations using tween library using the following code.

//for position
let moveT = this.entity.tween(this.entity.getLocalPosition()).to({x: finalPos.x, y: finalPos.y, z: finalPos.z}, isInstant ? 0 : this.moveDuration, pc.CubicInOut)
                    .delay(isDelayed ? this.moveDelay * cardNumber : 0)
                    .on('complete', function(){
                    });
                    
    moveT.start();

//for rotation
this.entity.tween(this.entity.getLocalEulerAngles()).rotate(this.frontrotation, rotationDuration, pc.Linear)
            .start()
            .on('update', function (dt) {
          
            })
            .on('complete', function () {
            });

And the both of the functions are executed after a settimeout call.
Now the issue is when we are putting playcanvas in background, the tweens are not working.
and when the playcanavas is moved to foreground only the rotation tween works and position tween doesn't works.
Can anyone help me out here?
thanks.

@yaustar
Copy link
Collaborator

yaustar commented Jan 3, 2023

Now the issue is when we are putting playcanvas in background, the tweens are not working.

PlayCanvas uses the animation frame callback for 'frame updates' and tween manager is dependent on the engine's update loop.

When the tab is in the background, the browser callback for animation is not called by the browser for the tab so no engine update is done while the tab is in the background.

and when the playcanavas is moved to foreground only the rotation tween works and position tween doesn't works.

Surprised that it isn't consistent. Can you provide a simple example project that could be investigated please?

@yaustar yaustar added the bug label Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants