# i dont understand lerp(here.x,there.x,1-0.5^timedelta)

For questions about using Classic.

### » Mon Apr 11, 2011 4:44 pm

K let's start with what I do understand.
I know the purpose of timedelta, to help you keep game speed consistent even when the fps changes. and I know that its the amount of time that has passed since last tick
I understand lerp(here.x,there.x,0.5). And why that would give you a nice ease out from one location to another. And I also understand how I can use ^timedelta in my own caps just based off this with no greater understanding

What I don't understand is the math logic behind using timedelta as an exponent
Supposedly this is how ashley did it in some example, and I tested it with unlimited and fixed frames and it seems to keep the speed consistent.

I just really want to understand why, mathematically, this should work. It makes no sense to me at all. If someone understands the math behind using an exponent, and how it creates the correct effect, id appreciate it. And just in case: no, I'm not satisfied just understanding That it works. I want to know Why it works
Spriter Dev
B
103
S
22
G
12
Posts: 3,286
Reputation: 17,153

### » Mon Apr 11, 2011 6:37 pm

There really is no significance, its just that 1-0.5^timedelta, or 0.011((1-0.5^1.69306434690952e-002)approximately) is a good percentage to start with... as far as the ease in, and out goes.
That plus its easy to dial in speed by changing 0.5 to anywhere from .9 to 0.000005.
B
179
S
50
G
207
Posts: 8,719
Reputation: 128,306

### » Mon Apr 11, 2011 7:16 pm

Also if you use lerp(here.x,there.x,timedelta*2/3) instead the motion is about the same.
B
101
S
39
G
134
Posts: 5,588
Reputation: 85,514

### » Mon Apr 11, 2011 9:38 pm

What does this do exactly? Interpolates based on timedelta? The lower the framerate the closer you are to one of points? If the lerp value from 0-1 doesn't change, then how does it ease in/out?
B
49
S
10
G
9
Posts: 1,224
Reputation: 8,480

### » Mon Apr 11, 2011 10:01 pm

.x is the same as get x, here.x, and is essentially the only thing that is changing.
Lerp(4,there.x,1-0.5^timedelta) is pretty much goggles. doh
B
179
S
50
G
207
Posts: 8,719
Reputation: 128,306

### » Mon Apr 11, 2011 10:43 pm

[quote="Davioware":1kda54yy]What does this do exactly? Interpolates based on timedelta? The lower the framerate the closer you are to one of points? If the lerp value from 0-1 doesn't change, then how does it ease in/out?[/quote:1kda54yy]

just think of it like lerp(a,b,0.5)
each tick it would go halfway to the destination.
as it got closer it'd be a lower and lower distance.
so it's a nice smooth slow down that looks like a cosine curve
Spriter Dev
B
103
S
22
G
12
Posts: 3,286
Reputation: 17,153

### » Tue Apr 12, 2011 3:29 am

Ok, I was thinking about two stationary points, with the 0-1 value being used to move, which is how I usually use lerp(). What wasn't made clear was that "here.x" is actually the sprite's own x. You should have said set "set .x to lerp(.x,there.x,1-0.5^timedelta)".

For this kind of movement like you want, I usually just do

set .x to .x+(abs(there.x-.x)/(somevalue*timedelta)).
B
49
S
10
G
9
Posts: 1,224
Reputation: 8,480

### » Tue Apr 12, 2011 9:45 am

ok, I guess my real question is what does
x^y
do when 0<y<1

I keep trying to google it, but not getting what I'm looking for. I'm used to exponents providing very different answers to multiplication, you know
5*3=15,
5^3=125
Spriter Dev
B
103
S
22
G
12
Posts: 3,286
Reputation: 17,153

### » Tue Apr 12, 2011 1:23 pm

Try thinking of it as a fraction.
0.5 = 5/10
Does that make more sense?
B
179
S
50
G
207
Posts: 8,719
Reputation: 128,306

### » Tue Apr 12, 2011 1:31 pm

nah
I just forgot honestly. what does a fractional exponent do?
isn't it something weird like 6 to the 1/5 power is like taking the 5th root of 6 or something?
if that's the case then it still doesn't make sense why it'd be equivalent...
wait wait
found it
http://www.mathsisfun.com/algebra/expon ... ional.html

yeah, I guess the confusion was thinking timedelta was an exact science. there's no way taking the nth root of something can give truly similar results to multiplying by some other random a/b.
so basically what you guys are saying is that they really won't run at exactly the same speeds when moving at two different framerates, even in a perfect world where you had a perfectly exact timedelta. so just come up with some random equation that seems to work, or use one you saw someone else use somewhere?
Spriter Dev
B
103
S
22
G
12
Posts: 3,286
Reputation: 17,153

Next

Return to Help & Support using Construct Classic

### Who is online

Users browsing this forum: No registered users and 1 guest