get lerp percentage complete?

Get help using Construct 3!

» Fri Aug 04, 2017 2:07 pm

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.
B
14
S
4
G
1
Posts: 81
Reputation: 1,143

» Fri Aug 04, 2017 2:56 pm

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)
B
178
S
50
G
206
Posts: 8,684
Reputation: 127,711

» Fri Aug 04, 2017 3:24 pm

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)
B
14
S
4
G
1
Posts: 81
Reputation: 1,143

» Fri Aug 04, 2017 3:39 pm

Yeah, no, but you could use unlerp as part of a timer.
B
178
S
50
G
206
Posts: 8,684
Reputation: 127,711

» Fri Aug 04, 2017 10:58 pm

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.
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

» Sat Aug 05, 2017 2:56 pm

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.
B
178
S
50
G
206
Posts: 8,684
Reputation: 127,711