Search Unity

Shared Timeline Track

Discussion in 'Timeline' started by olejuer, Apr 15, 2020.

  1. olejuer

    olejuer

    Joined:
    Dec 1, 2014
    Posts:
    211
    Hi,

    I am wondering, would it be possible, to have a Timeline Track that is shared among multiple Timeline Assets and kept in sync?

    Context:
    I am managing character actions with timeline, e.g., attack animations (play animation, play sound, play particle systems, activate hit boxes, etc.). These are becoming numerous and similar. Some tracks are even identical. Currently, they are redundantly setup in every timeline and there is no way to change all of them at once.

    Solution Attempts:
    So I turned to a custom behaviour that references a ScriptableObject asset with AnimationCurves. But this only works for some cases. The ScriptableObject that I actually want shared is the Timeline Track itself...
    I tried creating persistent assets of tracks using the [CreateAssetMenu] attribute. However, when dragging such a track into the timeline window, a track of a different type is created (?!). Also, it will most likely create a new instance anyway instead of referencing the asset.

    Any idea is welcome! Thanks :)
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    It's technically possible, but quite tricky to set up.

    An alternative is to use a separate timeline/playable director for the shared track, and then use a control track in each of the other timelines that need to reference it. The shared track would be a nested timeline of all the timelines that need it.
     
    olejuer likes this.
  3. olejuer

    olejuer

    Joined:
    Dec 1, 2014
    Posts:
    211
    Thanks, good idea. That will probably do. Will have to consider the performance impact of additional PlayableDirectors, though.
    I can throw in a custom track/playable to also set the timeline asset that is being played. That is something that ControlPlayableAsset could think about doing itself, maybe? The swapping out of TimelineAssets at runtime is a quite powerful feature, I think!
     
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    The additional cost of the playable directors is likely within budget if it allows you to share the timeline asset between other timelines. And the playable director itself can hold bindings to multiple timelines, so you can swap out the timeline asset without losing the binding. That would allow you to swap the timeline being run on the control track before playing the master timeline.
     
    olejuer likes this.