Can you make a timeline's values public?

I’m curious, is it possible to make the duation (or any value) of a timeline dynamic? For example if I wanted to allow the level designer to adjust the time/duration of a timeline, could I make the value public? i.e. if I set the timeline duration to 2 seconds but I’d like to allow someone to change it to 1 second or half a second etc. ?

There’s no direct way to change the duration value of a timeline at runtime, however since there is a way to change the playback rate of a timeline, you can use this simple workaround:

  1. Make your timeline 1 second in duration.

  2. Create a float variable that will act as the new, dynamic duration of your timeline.

  3. Get a reference to your timeline (Get )

  4. Set Playback Rate on your timeline to 1 divided by your new float variable.

Since your timeline is 1 second long, dividing 1 by the desired duration will result in your timeline playing for exactly that desired duration (1 / 4 = 0.25, 1 second timeline playing at 0.25 speed = 4 seconds).

Timelines tick once per frame, regardless of their playback rate, so this effectively changes the timeline’s duration.

That is indeed a really cool trick J Parent, thank you. I suppose you could also set up a branch and bool to make it faster than 1 second too. Create a public bool “Faster?” and then if true, multiply the timeline duration by 1 to speed up the timeline in the same way and if false, then divide by 1 like you suggested. Awesome stuff!

If you want it to go faster just enter a lower number in the float variable. This works both ways. The MyTimelineDuration value is literally the duration of the timeline.

1 / 4 (the duration variable) = 0.25 playback rate = 4s duration

1 / 0.5 (the duration variable) = 2 playback rate = 0.5s duration

Oh funny… shows how bad I am at math. I didn’t see how you could divide 1 by any number to go higher than 1 lol. But yes, it makes sense now that I think about it.

If you wish to change the timeline publicly, the best way to do this is by External Curves. You can add them into your timeline editor and then, if you wish to change it to different value/you change at beginplay which float curve variable you wish to include within this timeline.


image
image

If you wish to do it in a runtime, just add simply another curve.