Timeline / Lerp / Distance / Speed / Time - Math!

Hi there!

1. A Lerp, when used as I assume you tried it, will interpolate between the current position and the target position with a constant factor - this means, the object will get slower and slower, but mathematically never reach the target (it will come “infitesimaly close”). So that’s not the way to go here, unless you want this behaviour.

2. The simplest way to move an Actor as you describe would be something like this:

The vector (here with 1, 1, 1) holds the speed values, it will move in the direction with each tick. As long as the values are small, it’s fairly smooth
The problem with moving via event tick is that you dont have a constant framerate, making it hard to define a very specific movement speed. You’d have to take delta seconds into account

1. (!) Keep in mind that an actor usually has a collision mesh/gravity and might collide with terrain or other stuff in your world. If you don’t want that, set the teleport bool, or disable collision entirely for your actor.

Also (!) Gravity might be enabled. Since you want to move in z direction (which is up), that might counteract your movement.

1. With a timeline, this works:

with the according timeline (a vector with a constant value to be added to the location):

The Timeline vector are the simple constant speeds. Instead of calculating how long it should move, i’d check for the distance and stop when close enough. (like a slider on a rail triggered by a switch thats supposd to go somewhere) That would be something like this:

The branch stops the timeline movement when the actor has reached it’s target -
Sidenote, in case you don’t know: float comparisons are usually not flat 0, so we have to use the distance within a certain range. If you just check “Target position == my position”, that might never happen, as float 0.122 is not equal 0.121, but we consider it to be the same position.

1. There are other ways - especially for characters, AI Controllers are the way to go.

I dont’ know if this is the best option, but it’s the directest one I came up with. Hope it helps!

Cheers

@Sohno is right… by the way your actor is moving much too quickly than the timeline setting, sounds like you’ve directly connected the actor location to one of the 2 inputs into the lerp node (so it is correctly - if confusingly- constantly jumping to it’s desired position (yep, this had me scratching my head too initially))

Something like use the lerp to interpolate between 2 vector location variables, then feed the result variable to the actor location.

Hi all,

Ok, I suspect a large part of this issue will be my limited math skills but here goes…

I have an object which I want to make move on the Z axis. Starting at one value and ending at another.

I have a Timeline in place and have a linear 0 time 0 value, 1 time 1 value setup.

On the Update pin I have a Lerp(vector) with a starting position and the ending position and the alpha plugged in.

When run, the object moves from top to bottom - BUT - it moves far to fast.

I have variables for the calculated distance it has to travel, the velocity at which it should travel, and a final variable wihch is the duration this travel should take… based on time = distance/speed etc.

What I’m unsure of is how to plug all that into the Timeline and Lerp nodes… I did plug in an arbitrary divide on the alpha with the value of 12. This slowed the movement down, but then the object never reached the final destination.

If I could just put these values into the Timeline via Blueprint, e.g. add the keyframes, it would be a lot easier, but I haven’t found any way to do that, and every example and offer of help I see/get seems to suggest this 0-1 thing.

I’m struggling to understand how I can influence this, I have no idea over what period of time this is running. I set a length to 1 but nothing in the documentation indicates whether that’s one second, one frame, one wink of a farmers eye… who knows!

My gut feeling is that I should probably be multiplying the result of the lerp by perhaps the desired velocity or something but I honestly have no clue, also feels like maybe I should be multiplying by deltatime too…

I considered setting the playback speed of the Timeline to something else but again, no idea what its already running at so no idea how to change it.

I also consider setting the “length” property via Blueprint, once I knew the duration above, but if I do that, then I have a keyframe at zero, another at 1, and then the length could be say 27, with no keyframes after 1?!

Gahhhh!

Note, I still can’t make my replies/comments visible due to moderation, so if you don’t see a reply after you have perhaps replied, it’s not me being rude - honest!

If you want to slow down the travel, just change the length of the timeline

Or, you can change the speed of the timeline using:

Hi,

Yes, I can see I can do that, but how can I accurately calculate what those values should be?

If I have an object that needs to move 1000 units and has a velocity of 100 units per second, then that would equate to 10 seconds. I can’t set the “length” programatically because the keyframe will still be left at the 1 second point in the timeline…

That would only leave changing the playback speed. So, what is the default? I’m guess a value of 1, but again, what does that 1 represent?

Having calculated the distance between two points, setting a velocity, the duration is now known, but I can’t see how to plug that in.