Jump to content
Search Community

Variable animation duration with fixed in/out ease duration

SauceCode test
Moderator Tag

Recommended Posts

Hi !

 

Initially, I work alone without asking help (with lurking some forums and stack overflow threads), but, I am completely stuck for days, so, here I am :) 

 

 

Background :

 

I am working on a top down game with Pixijs with one problem: manage as many entities as I can before the simulation slow down. I heard about gsap and I would like to "convert" my manual translations with gsap animations. For now, all animations are okay, except :

 

TLDR :

How can I animate a keyboard activated movement for a ship with a constant speed of 10px/s with a fixed 1s acceleration/deceleration ?

 

Tried solution (in codepen) :

As I don't know the destination it looks that I can't tween with `gsap.to`. For now, i am easing a velocity value. Added in a custom loop to the position of the ship each frame (with gsap.ticker). With this solution, I am not using gsap each frame so ... no lag smoothing and frame interpolation.

 

Thanks you for your time 🙏

 

See the Pen LYpGqZz by SauceCode (@SauceCode) on CodePen

Link to comment
Share on other sites

Very interesting ! I will look at this for key handling.

 

 

The question that remains is by doing a gsap.ticker.add(() => { pos.x += velocity.x }),will we have cpu sluttering on animation that we avoid using a gsap.to() ?

 

Thanks :)

 

 

Link to comment
Share on other sites

gsap won't eliminate stuttering. You might even want to turn off lag smoothing for a game. 🤷‍♂️

 

But you can compensate for some lag in a ticker, like here.

https://pixijs.io/examples/#/gsap3-interaction/gsap3-tick.js

 

app.ticker.add((delta) => {
  
    // use delta to create frame-independent transform
    container.rotation -= 0.01 * delta;
});

 

 

 

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...