# Is there a glitch with "lerp"?

For questions about using Classic.

### » Tue Aug 04, 2009 4:06 pm

The command I have going is, "Options: Set Y to lerp(.Y, Options.Y+16, 1 - 0.00001 ^ TimeDelta)"

I would imagine this would set the Y coordinate of every seperate Options object to itself + 16. But when I try it out, it doesn't stop 16 pixels below itself, all the objects keep moving on, and on, and on.
B
4
S
2
G
4
Posts: 164
Reputation: 1,878

### » Tue Aug 04, 2009 4:18 pm

I'm still a little vague on what you're trying to do
but timedelta is for timebased things
like objects moving and animation that happens overtime

unless you want the y-coord to be changing, you should have that there at all

aside from that, I kinda don't know what you're trying to do
but it sounds like you might have a picking issue in there as well
but as an example

lerp(a,b,t)
gives you a number between a and b, determined by a 0 through 1 value of t

lerp(2,4,0)
would be 2 because it's all the way to the first number
lerp(2,4,0.5)
would be 3 because it's .5 of the way to the second number
lerp(2,4,1)
would be 4 because it's all the way to the second number

also, if you just want something 16 pixels below where it already is
you can just do y = .y+16
Spriter Dev
B
91
S
21
G
12
Posts: 3,246
Reputation: 16,573

### » Tue Aug 04, 2009 7:04 pm

Yeah you cant tell it to set position to itself, because it will set every object to new coords.
You might try using families, and use the pick conditions.
B
163
S
48
G
100
Posts: 7,460
Reputation: 72,042

### » Tue Aug 04, 2009 7:52 pm

There is no glitch with lerp. The event is running exactly as you wrote it.

Take a look, it's effectively:

lerp(.Y, .Y + 16, <some small value>)

That will always produce a value slightly greater than just .Y, hence the object moves down. I guess that's in an event which is continually true so the object keeps going.
Scirra Founder
B
362
S
216
G
75
Posts: 23,120
Reputation: 180,504

### » Tue Aug 04, 2009 9:23 pm

This sort of thing didn't occur when I had programmed these objects to move themself + 16 in the Y coordinate. But lerp seems to act differently, it seems... So I guess I'm going to have to manually copy and paste a bunch of code for each and every single object?
B
4
S
2
G
4
Posts: 164
Reputation: 1,878

### » Tue Aug 04, 2009 9:57 pm

What you are actually trying to do? If you are setting objects to move to 16 pixels below themselves, they shouldn't stop either, as they don't stop with lerp. If the condition keeps evaluating true, the actions will happen again an again.
B
3
S
2
G
5
Posts: 263
Reputation: 2,201

### » Tue Aug 04, 2009 10:16 pm

It's kind of hard to explain without showing you. As it turns out, I CAN exceute my old method with lerp, if only I change exactly what it used to say for Y movement. It doesn't come out looking as smooth though.
B
4
S
2
G
4
Posts: 164
Reputation: 1,878

### » Wed Aug 05, 2009 1:54 am

you're being quite vague though, so no one knows what you mean
I can't even make an example, because I have no idea what you're talking about

move smoothly? so you do want it to keep moving?

explain a little further, you don't have to give away your game or anything
you can just say
I have a sprite, I want it to start moving down
and stop at a certain point

or whatever

there's a good chance we can help you do what you want, with or without lerp smoothly,
but right now, I'm not sure what you're asking
Spriter Dev
B
91
S
21
G
12
Posts: 3,246
Reputation: 16,573

### » Wed Aug 05, 2009 3:01 am

Well, here's the pause menu:

Here's how I want it to look when you open a selection:

Same with this option, I want the other text below it to be pushed down...

And in selections with sub-menus, or whatever you wanna call it, like this, everything else still gets pushed down and such... The normal menu text, AND the selection's text... It's hard to put it in words, but you can see by this picture what I mean.

Right now, I have to manually program lerp for each and every piece of text. This is the event for RETURNING everything back to normal, when you cancel back out to the regular menu. It was kind of like this in the first place, however...

These are the events for when you open up the "Items" menu. As you can see, I have to manually program every single piece of text below "Items" to move into place.

I sort of had a system going on with just moving them by Y position, but it didn't move smoothly like lerp does, and simply changing, "move Y by yourself +16 until you get to a certain point" to lerp DID make things move smoothly, but lerp just came to a sudden stop. I'm sure there's a way to move all these things WITHOUT manually programming each and every piece of text for each and every menu selection, probably Ashley or... ANYONE else here would know how, but I have no idea.
B
4
S
2
G
4
Posts: 164
Reputation: 1,878

### » Wed Aug 05, 2009 7:38 am

quote. all the objects keep moving on, and on, and on.

at start of expandable menu click trigger once set pvariable moveto to .y+16, set pvariable oldy to .y. when menu is expanded lerp to pvariable moveto. when object reaches moveto stop the event. when menu is collapsed lerp to pvariable oldy when object reaches oldy stop event .
B
2
S
2
G
4
Posts: 259
Reputation: 1,968

Next

Return to Help & Support using Construct Classic

### Who is online

Users browsing this forum: No registered users and 5 guests