How do I use lerp with timescale set to 0?

0 favourites
  • 3 posts
From the Asset Store
A whole set you need to create a gorgeous winter 2d game
  • Hey people, I'm stuck on this one for a while.

    The goal is to have XP bar with lerp continue working after pausing the game (global time scale 0).

    I've tried setting the XPBar time scale to 1 after pausing the game but it still does not work. Probably because the action for lerp is in every tick event. Is there a way to use dt of the object (after I set it's time scale to 1) like every XPBar.dt seconds or something like that?

    I've also tried using the dt within the lerp itself:

    lerp(width,xpbarwidth*(xp/maxxp),XPBar.dt*4)

    But it does not work.

    The one workaround I found is adding all objects to family and setting their timescale to 0, but that raises some other problems unfortunately.

    Any help would be greatly appreciated!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can use a different expression when timescale=0 with a fixed value instead of dt, for example 0.016 (which corresponds to 60 FPS).

    Or calculate your own dt from fps value:

    If timescale=1 : lerp(width,xpbarwidth*(xp/maxxp),XPBar.dt*4) 
    Else: lerp(width,xpbarwidth*(xp/maxxp),(1/max(fps,30))*4) 
    
  • Yeah, that worked perfectly.

    Thank you very much!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)