How to change timeline duration and have updates relate to new time?

I’m using a timeline to move an actor over the period of 2 seconds. I accomplished this by setting the timeline to run for 2 seconds, added a float key of 0 at 0.00seconds, and another of 1 at 2.00seconds. Then I used each update as the alpha in a Lerp to get a location between starting and ending position.

This works fine, but I’m having difficulties figuring out how the length of the timeline works and how it affects keys. EG: If I “Set New Time” to 3 seconds, how do I get the key to automatically change from 1 at 2.00seconds, to 1 at 3.00seconds?

2 Likes

I’m not 100% but i think the ‘set new time’ function actually just jumps the current location along the timeline to that time, rather than change the length of the timeline.

What I have done when I wanted something like you’re trying to do, is create a timeline of duration 1 second, with value going from 0-1. You can then grab a reference to the timeline and use the ‘set play rate function’ to change how fast it runs. Set play rate to (1/desired duration) and you’ll get what you want. So in your case, if you have a timeline of length 1 second, and set the play rate to 1/3, you’ll get a timeline that now takes 3 seconds to complete.

I’ve only used this with linear float tracks though, I haven’t really needed to do anything else with it, i’m not sure if there’s a way to move keys in code like you’re after (but i haven’t really looked either).

22 Likes

I’ll give that a shot and let you know. This may just work.

EDIT: Worked PERFECTLY. Thank you!

Just thought I would chime into this old post as well but first off thanks as this worked well for what I was needing to use it for and it makes reusing already existing timelines. So I made a visual reference as to how I set up one of the instances of the timeline to resale base on a time of minutes if anyone in the future may run across looking to do the same thing.

&stc=1

13 Likes

Thanks Guys.
You Guys are Angels

Very useful BP for setting speed. As a side note for others, You got the timeline as a target by dragging it in the BP and choosing Get.

3 Likes

Thanks for the breakdown, all. Very helpful! I made a minor to change so it works regardless of timeline duration.

Cannon Firing is the timeline. Fire Rate is the variable driving the play rate.

timeline.png

6 Likes

From the components list in the ‘My Blueprint’ window… Took me a bit to figure out where to drag it from as my components list was collapsed.

3 Likes

You can also right click in the bp and type the name of the timeline, it will show up as a getter.

1 Like

This doesn’t do anything, You’re doing
X
________ which is equal to 1/Rate
X * Rate

What you wanted to do is Fire Rate/ Get Timeline Length

Thank you a lot!