Timeline / Lerp / Distance / Speed / Time / Maths... ?

Hey @ClockworkOcean,

I can’t get anywhere with that AnswerHub site, its driving me insane, none of my replies are appearing so I can’t ask any further questions to the replies you’ve kindly given…

Can we try here please… I’ll happily post over there again when whatever the issue with the moderation is resolved, its been a day of pain using it.

So, the question was…

If I have an object that need to move from point A to point B (vertical descent), how can I control the speed of that movement when using Timeline and Lerp? Currently I have this;

If we were to say that the actor (A) was at 1000 on the Z axis, and the Impact Point (B) was 0 - how do I plug in the velocity variable I have set (a value of 300) to make the movement between A and B take the correct amount of time?

I saw your reply about setting the “length”, but if I do that via Blueprint (as all of my values are dynamically created) - then I’ll have the keyframe that is at time = 1 on the image above not at the end of the length for the Timeline, so it will still hit the value of 1 after just 1 second (assuming these are seconds). There doesn’t appear to be anyway to add/set/move keyframes via Blueprint after creating the Timeline. So that feels like that option is out.

If I were to try and change the playback speed - how am I to calculate what that should be? At the moment, I’m assuming its set to a default of 1. So presumably the 1 second length of the Timeline takes 1 second. If it were set to a playback speed of 0.5 then I would assume that the Timeline would take 2 seconds, despite being set to 1 second for a length etc.

If so, would I need to divide the initial playback speed of 1 by my calculate duration for movement between points A and B? e.g. 1000 units / 300. If so, isn’t that going to give me a value here of about 3.333 - which would then be 3 times faster than what I currently have?

Any help would be really appreciated. Sorry to drag you over here, but AnswerHub just isnt working for me, not until it allows replies/comments for me. :frowning:

Mistake in my maths above, so the initial playback speed of 1, divided by 3.3333 would be 0.3, thus slower not faster…

BUT…

How do I know how much distance has actually been travelling in that 1 second length of Timeline? That alpha that is generate for the Lerp? How do I know whether the value of 1 is correct or whether it should be something else?

It strikes me that if I could just put in the actual values this would all be so much easier… if I could then the playback speed would be 1. The length would be my calculated duration of 1000/300, thus 3.33333. The first keyframe would have a value of 1000, and the second would have a value of 0 and be at 3.3333 seconds on the Timeline. Yet I can’t do any of that.

…and should I also not be concerned about using DeltaTime in all of this somewhere to make the movement frame rate independent?

Sorry you’re having some much of a hard time with AH mate, I hope that gets sorted out.

Anyway…

Golden rule #1 when working with times, you have to calculate the start and end points first, THEN go into the timeline.

You’re using that GetActorLocation node, which is going to be screwing up the process.

If you want to move an object from A to B ( whether in Z etc ), you can do it like this:

Did you get it working?

I can tell you for sure, putting absolute values in will lead you down a very curvy garden path indeed. And then you will eventually end up with the 0-1 lerp method. Promise… :slight_smile:

The Alpha only ever goes from 0 - 1, it doesn’t have any other values.

You can put values in if you do it like this:

But you can see that’s going to start to be a pain in the butt, because you have to keep figuring out where your mesh it before you do anything to it. If you move your mesh, it wont work and you have to re-code everything again…

Sorry, only just saw the bit about delta. You only need to compensate for delta time when using interp nodes. The great thing about timelines is they always complete in the correct time regardless of frame rate. Here’s a good vid about it:

( ■■■■, trying to find it )

Nope, can’t find it right now, but there’s a good vid on this channel:

Me too! :frowning:

So, I’ve updated what I had to not keep getting the Actor location. When I was using that it was slowing down before the end, as it could never reach the full end location. By setting the start location first, to the position of the actor and then running it, I get some other problems… sigh… (I have been doing this ALL DAY!)…

So, if I don’t set the playback speed, it drops far to fast… if I do set the playback speed, its now ridiculous too slow… when I was setting the actor position each time, the value I am setting for the playback speed felt right…

I am setting the playback speed as 1.0 / DescentDuration.

DescentDuration is calculated by taking the distance to travel and dividing it by the velocity…

So, if I use the set the values first approach, what can I do to resolve the velocity issue?! Feel I’m just going round and round with this… change one thing and the other part breaks… fix that, then this part breaks… I don’t feel like what I’m trying to achieve is something particularly complex… not sure why I’m having all these problems…

Thanks for the replies and the info on delta too, I’ll check the video out in due course… thoughts on the velocity now would be hugely appreciated…

No, I meant actually in the timeline graph…


So in the above… if I set the first keyframe to have the value of the starting Z value… then the second keyframe of the floor, z= 0… the “length” would then need to be my distance/velocity value…

Surely with that, it would actually end correctly? But I can’t do that. Each object is randomally spawned, so these values would to be passed in via variables, and that’s not something it seems to do.

I can’t get my head around how the lerp thing is working at all… the timeline values just seem really arbitary… for example, WHY have a length of 1 second? Why not 50 or a million!? if its just “pick a number and put it in” its kinda arbitary. Is this 1 second then split up by each frame… e.g. it goes from 1000 on the Z to 0 on the Z in one second… but the Update pin spews out a value for each frame within that one second?

I just don’t get it… and as always the UE4 documentation is as useful as sticking hot pins in my eyes… :frowning:

Key 0 (time 0.0, value 0.0), Key 1 (time 1.0, value 1.0)

Length … How long you want it to take the timeline to get from value 0 to value 1.

Hi, thanks for the reply,

If that length is to be calculated programmatically and then set programmatically… how do I update the key at time 1.0 to then be at time <new length> ? e.g. shifting that second key to the end of the new length. Example… new length set to 5 from 1. Keys at time 0 and time 1. With the new length of 5, there is now a key stuck at time 1. How to move that to time 5?

Best to simply use the 0 to 1 key set up and a base length of 1 second. Then you can use Set Play Rate to adjust the speed.

https://docs.unrealengine.com/en-US/…ate/index.html

Rob, this is getting to be a mess, maybe start a new thread of PM me with a spec of what you want ( not what you have so far ), if you don’t any fruitful answer here…