Is there a glitch with "lerp"?

This forum is currently in read-only mode.
0 favourites
From the Asset Store
Tweakable and easy to use effects for your projects.
  • 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.

  • 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

    <img src="http://upload.wikimedia.org/wikipedia/commons/8/89/Bezier_1_big.gif">

    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

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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?

  • 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.

  • 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.

  • 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

  • Well, here's the pause menu:

    <img src="http://i77.photobucket.com/albums/j42/Dreamer_Kisai/PauseMenuExample01.jpg">

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

    <img src="http://i77.photobucket.com/albums/j42/Dreamer_Kisai/PauseMenuExample02.jpg">

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

    <img src="http://i77.photobucket.com/albums/j42/Dreamer_Kisai/PauseMenuExample03.jpg">

    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.

    <img src="http://i77.photobucket.com/albums/j42/Dreamer_Kisai/PauseMenuExample04.jpg">

    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...

    <img src="http://i77.photobucket.com/albums/j42/Dreamer_Kisai/PauseMenuExample05.jpg">

    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.

    <img src="http://i77.photobucket.com/albums/j42/Dreamer_Kisai/PauseMenuExample06.jpg">

    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.

  • 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 .

  • 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 .

    Let me see if I got this straight... I start an event that says... When you select a menu... trigger once... set private variable to whatever Y + 16 would be. That's the math for that. So it'd be like, "Set Options private variable to Options.Y + 16"... and that'll work for every single individual one?

    And then we do the lerp movement with .Y being the starting point, and the private variable being the end point? And we have to tell it to stop once it gets to that point? How, exactly? Would it matter since this is being done with "trigger once"?

    And then, when cancelling back, we do the same thing over, but instead of adding on the Y coordinate, we subtract, right? Set the private variable to Options.Y - 16? Then do the lerp movement all over again?

    I assume, since I KNOW this is going to indescriminately affect every single "Options" object, that we throw in a condition that only the options BELOW the selected menu, and are aligned in the same X coordinate will be pushed down like this?

    But did I understand your directions right? I AM pretty dumb at this whole thing, so I'm just making sure I got it. ^_^;;; Just breakin' it down to simplify it for myself.

  • i dont do good explanations so someone else might jump in. just make sure trigger once when setting the pvariables. the movement wont be triggered once. i said stop event because lerp will still run when it reaches destination but it wont go anywhere, i believe. might as well stop extra cpu use. but thats just out of habit. someone else will tell you if it saves anything worth extra conditions for. and you should put the ones you want to move when clicking button in different family and run events on family. you could do it with out family though. family might be easier for you.... again unless someone else jumps in with how to do with pvariable and for each ordered.

  • Seems like an okay idea, and I even tried doing it as a function, so it could be done universally with each and every menu item, but upon testing it out, it turns out that if I have it select every menu text BELOW the cursor, it DOES add to each one of their private variables individually, and ONLY for the ones below the cursor. However, trying to move Options by Options.Y + 32 glitches them all up. lerp wouldn't work, so I tried just setting their .Y to whatever their private variable is, and it sends every single Options object to, and I'm copying and pasting this, "-8.64691e+018".

    So setting the private variable to itself.Y + 32 or whatever... that works fine, I checked it in debug, and every Options object below the cursor DOES have a unique variable that coresponds with its own Y position. Moving them at all, on the other hand, seems glitchy.

  • In fact... I don't think you can do lerp movement with a private variable at all. Even setting the private variable to a set number like 300 or something makes all of them screw up.

  • i can be arsed to read the entire wall of text that this thread is, but from skimming im pretty sure youve misunderstood what you yourself are trying to do

    [quote:8gkw087h]Options: Set Y to lerp(.Y, Options.Y+16, 1 - 0.00001 ^ TimeDelta)

    this equation doesnt need lerp, infact i have no idea why your using it. all its doing is setting the y position of watever.y, to a position somewhere in between its current y position and options y position +16. the value your using as the "t" value makes no sense. its a number that is never changing except for what time delta is so in short, your lerp targets are always moving, so your objects will continually move. (is options moving aswell?) what you should be doing is storing the initial y position for each object in a variable, called intY, and then the point which you wish it to get to (options.y + 16?) in another value like tgtY DO NOT CONTINUALLY UPDATE THESE, THEY ONLY NEED TO BE SET ONCE, LIKE AT START OF LAYOUT. then u use those two variable for each objects lerp coordinates, and then a third one for the t value so something like lerp('intY','tgtY','t')

    u modify t in actions completely unrelated, by adding or subtracting small increments (0.01) from it until it reaches 1 or 0, then u stop.

    you wont have to do all this for each object because you could put each one in a family with all these variables, and only control them when those object meet current conditions.

    if you want the movement to smoothly accelerate and then smoothly decelerate, you "cosp" inplace of "lerp"

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