get lerp percentage complete?

0 favourites
  • 6 posts
From the Asset Store
A whole set you need to create a gorgeous winter 2d game
  • Is there any way to get the lerp percentage complete from 0 to 1?

    example,

    set value to: lerp(current value, 200, 12*dt) can give you value but not lerp percentage.

    so when value is at 100 the lerp would be 0.5 half way, how do i track it current percentage complete, bare in mind the start and end value might be anything.

    Thank you.

  • 0 to 1 is a percentage, however using like you are results in it never getting to 1, or 100%

    You have to realise that current value is the only value that's changing.

    In order for it to work as a percent you would have the start value, to the target value.

    lerp(startvalue,targetvalue,0.1)

    lerp(startvalue,targetvalue,0.5)

    lerp(startvalue,targetvalue,1)

  • Thanks but i don't want to set value by a percentage i want to convert the current value back into its lerp percentage at its current stage.

    Reading the manual again i think i need to use unlerp.

    lerp(current value, 200, 12*dt)

    unlerp(start value, 200, current value)

  • Yeah, no, but you could use unlerp as part of a timer.

  • C = lerp(A, B, 12*dt)

    The 'lerp' is of no importance. See it as a range.

    C is in the range (A to B), where B = 100 and A = 0%

    Say A = 2 and B = 6. Then the range is 4.

    Then 100% = 4

    Normalised 1% = 4 / 100, or 1 step = 4 / 100

    Say C = 2 ... how many normalised steps to make that 2 ? Well 2 / (4 / 100) = 50 ... To 100 that is 50 %

    The lerpfactor goes from zero to 1.

    So in .. 2 = (lerp,4,6,x) ... x = 0.5

    Generalised.

    lerpfactor in % for C between A and B = C / (B-A/100)

    That also gives negatives. When A is bigger then B. Up to you how you wrap you mind about that.

    For me that just means that the range has a negative growth.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here's an example of lerping with set values.

    https://www.dropbox.com/s/wribni5vyhych ... .capx?dl=0

    Note I think the ease out is exaggerated due to basically lerping a lerp.

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