Can you make a timeline's values public?

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.

1 Like