need help with lerp

0 favourites
  • 7 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • I create four buttons on the right side and when i touch button '1' set variable 'slajd' to 1 so when 'slajd' is 1 lerp object to position x and opacity to 100 (all works fine) but i have second condition- when 'slajd' is 2or 3 or4 set lerp to start possition x and set opacity to 0.

    When i set 'slajd' to 2,3,4 my lerp behave weird.

    Please take a look at my capx

    dl.dropbox.com/u/44710358/depocyte.capx

  • bump

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Change your lerp(a,b,c) to a-lerp(a,b,c). If you do the math you'll see the pattern. I'm heading out the door at the moment, or I'd spend more time explaining - sorry.

  • blackhornet what do you mean 'a-lerp' ?

  • lerp(a,b,c)

    lerp(100,0,.9)

    a - lerp(a,b,c)

    100 - lerp(100,0,.9)

  • blackhornet can you explain what is differences between?

  • Actually, I've had another look and there's a number of issues here. Lerp isn't the biggest one. Lerp really wants to go from low to high, not high to low, so you need to invert the math, which is why you have to subtract the lerp value from the original. The manual gives the math for lerp. You can try it manually.

    The real issue is Wait! Wait seems to cause more trouble than it does good. If I disable all of the waits, things work again. You have to remember that a true condition runs every tick. So for example, slajd=1 was running many times, calling Wait every time, so there are a lot of waits stacked up by the time you press the second button, which means all of those lerps moving the opacity up where still there, fighting with the slajd=2 code which is trying to move it down. That's why everything was jiggling back and forth.

    You need to change your code to use timers, which there are many threads on, to get the timed behaviour you are looking for. Here's the changes with all waits turned off for the moment, and the cytometriaprzeplywowa lerp altered. You can see it fades slowly, where all the unchanged ones disappear almost immediately.

    Also you should make sure your variables get set to zero along the way. For example, slajd=1 stays running that code forever, until you press some other button. Same for wybrany.

    sample (change the ZIP to CAPX).

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