Search Unity

Blending the timeline in a PlayableDirector

Discussion in 'Timeline' started by Duffking, Jan 23, 2018.

  1. Duffking

    Duffking

    Joined:
    Oct 3, 2014
    Posts:
    24
    I know you can blend from the animator into an animation clip in a timeline assigned to a playabledirector using the ease in/out function, but I was wondering if it was possible to do this between timelines - blending between two timelines in one playabledirector. For example, lets say I have a character with a playabledirector who:

    1. Plays a looping idle timeline until the player interacts with them, then
    2. Plays a timeline where they transition to a listening-to-player timeline, then
    3. Plays a looping timeline where they are listening until the player exits the interaction, then
    (3.5. Switch to a different timeline if the character's mood changes or starts speaking)
    4. Plays a timeline where they transition to an idle timeline, then
    5. Plays the looping idle timeline again until the player interacts again

    As well as containing some body animations, the timelines also have some particles etc related to what that character is doing.

    I can switch the timeline assigned to the playable director on the fly nicely, but is it possible to blend between, say, 1 and 2? Lets say the idle animation is fairly active and the character moves their arms about quite a lot during it. If we change to the timeline at the 100th frame, their arms might be quite some distance from where the transitional timeline has them at the beginning, resulting in a very visible snap between animations. I'd really like to blend from wherever the character's arms were positioned in the previous timeline, into where they are at the beginning of this one.

    Since I don't know exactly when the player will cause the character to switch from one state to another, I need to switch the timeline on the fly, especially if I want to have different "listening" states depending on the character's mood, as it could switch at any time depending on dialogue. Obviously in an animator I can do that, but is this possible when controlling a character's animation only in timeline? Easing in doesn't really help here since I'm easing in from whatever the animator's doing rather than the previous timeline.
     
    ModLunar likes this.
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    This is a perfect example of combining timelines with state machines. This isn't available yet, but is coming in a future release.
     
    Lars-Steenhoff and ModLunar like this.
  3. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    That sounds pretty cool!
    State machines as in mecanim (Animator window)? Or some new thing?
    Or maybe even having timelines as "nodes" in the animator?
     
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Along those lines for sure. The goal is to to have timelines (or any playable asset) as states, with blending supported between them.
     
    ModLunar and Lars-Steenhoff like this.
  5. ModLunar

    ModLunar

    Joined:
    Oct 16, 2016
    Posts:
    374
    I was literally just looking for this today! I can't wait till we can do something like that :)
     
  6. Duffking

    Duffking

    Joined:
    Oct 3, 2014
    Posts:
    24
    Hmm interesting to know that something's coming, for now I guess we'll have to look into some kind of attempt at a solution on this end. We're using behaviour designer to choose which timeline to swap in currentlly.
     
  7. Duffking

    Duffking

    Joined:
    Oct 3, 2014
    Posts:
    24
    Do you know of any particular timeframe for this feature?
     
  8. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    It's in development, but early in development, so likely still a couple of releases away.
     
  9. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,525
    Sunriser likes this.
  10. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,978
    Alverik likes this.
  11. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    It won't be in the 18.x release cycle, but that doesn't mean we don't feel it isn't important. In fact, what is being released is taking us in that direction.

    For 2018.3, we are really cleaning up root transform/scale issues that have been lingering on timeline for too long. Those fixes proved far more challenging that we estimated, and it took a few different approaches, but the result is something that will make blending timelines more intuitive and robust.

    Other fixes that are timeline specific we are working on (or will be soon), are being done with an eye towards being able to blend non-animation tracks.

    There's another thread where I posted a workaround to make blending animation tracks in timeline work from script. Some people (both inside and outside of unity) are using that for blending animation tracks. Hopefully we can post their samples of that working in a real-world scenario.
     
    MadeFromPolygons likes this.
  12. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,978
    @seant_unity
    Thanks a lot. I have been making some really good advancements with my use of timeline and playables. Manged to crack custom timeline assets + tracks for all kinds of useful things. Just started to understand the base playable system (for playable graphs, not just timeline stuff). I now am at the point where I believe i know enough to make a giant playable graph system that can act as a big animator controller style system with blending (for example to blend between clips for idle and running).

    The last bit of knowledge is how to get these "states" to blend to other states. I do believe with what you posted this will be more doable now :)

    So some questions on that "workaround" (solution imo):

    - So it essentially is reading two timeline assets, getting the track that is similar and then syncing up (blending) their weights from the weight at output of one, to weight of start of another?
    - Could this be used to fade a multi track timeline to another multi track timeline (same tracks in same order but potentially different bindings)?
     
  13. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,978
    @seant_unity can you explain how you would blend from one timeline being in control to another, rather than from timeline to animator in control?
     
  14. Alverik

    Alverik

    Joined:
    Apr 15, 2016
    Posts:
    417
    Any word on this? It would be really useful in a turn based combat game I'm prototyping...
     
  15. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Unfortunately it is not something that will be released in the 2019.x cycle. We are very much aware of how important a feature this is, and the interaction between state machines and timelines is something that gets a lot of focus during our discussions.

    The changes in root motion in 2018.3 was a step in the direction of this feature. The scene offset mode was made to improve timeline->state machine->timeline transitions. There are other problems that we haven't settled on a solution to yet, for example, how to blend non-animation tracks, and UX issues for binding multiple timelines. However, we aren't actively tackling those issues, as we came to the conclusion that the existing state machine may not be well suited to this.

    @JamesB pointed out in this thread https://forum.unity.com/threads/animator-statemachine-for-timeline.463803/, that the transition to a DOTS architecture (i.e. works with the new ECS architecture) has started for both timeline and animation. This is true, part of our development is working towards a new architecture that is much more performant. It's still very early but one of the goals is to have these systems (animation, state machines, timelines, compositors, etc...) work together as seamlessly as possible.

    It's possible we will still release a solution, in whole or in part, to this for the existing non-DOTS architecture. It's something we really want to solve, and everyone sees the benefit. The solution may be in the form of an additional package, or sample, or maybe just add in support for the pieces to make it work. I'm aware that some studios have custom solutions for this, and there may be some on the asset store that I'm unaware of.

    I hope that clears this up a bit. If people have custom solutions that they want to share, please share!
     
    OlliQueck and Alverik like this.
  16. Onat-H

    Onat-H

    Joined:
    Mar 11, 2015
    Posts:
    195
    Any update on this? It would be helpful to know if this is something that's still being worked on.
     
  17. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Unfortunately no real updates on this, what I mentioned in the previous post still applies. We are still working on a transition to DOTS, which includes better integrations with other DOTS packages like Visual Scripting and Animation to make transitioning between timelines easier, but we haven't officially released anything that would help generalized blending of timelines for the existing Timeline/PlayableDirector.

    I've seen a few systems/prototypes/samples since that post that use timelines as state machines that require that all animation tracks ease-in the first clip on the track.

    The general idea on them is a MonoBehaviour script which acts like the playable director, but builds and manages multiple playable graphs, one for each timeline asset. TimelinePlayable.Create is used to create the graphs, the PlayableOutputs are bound manually after creation. The main advantage of this approach is the graphs aren't destroyed and recreated, then are simply played when required.

    It also uses the PlayableDirector, but for authoring the timelines and storing bindings only.

    The assumption is that going to a new state always starts from the beginning, so the ease always acts as a blend.
     
  18. ThatMunk

    ThatMunk

    Joined:
    May 17, 2017
    Posts:
    12
    Can you please link to any of these examples if possible?
     
  19. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    I don't know if/where they are available. I would have loved to have been able to post at least one of the solutions.
     
  20. TheVirtualMunk

    TheVirtualMunk

    Joined:
    Sep 6, 2019
    Posts:
    150
    Would I be on the right path to blending timelines if I tried doing something with the playable api?
     
  21. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Yes, that's really the only way to do it.

    One complication you will inevitably run into is the timeline playable writes the blending weights on animation playable outputs and their sub-graphs every frame right immediately before they are evaluated, so changing the weights elsewhere always gets overwritten.

    The workaround I posted in other forums is to create new AnimationPlayableOutputs on the playable graph after the timeline graph is created, and have these new outputs point to the old sub-graph, and then unbind the originals. That way you can control the weights of the animation tracks manually.
     
  22. TheVirtualMunk

    TheVirtualMunk

    Joined:
    Sep 6, 2019
    Posts:
    150
    I guess you are referencing this thread?
     
  23. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Yes, that is one of them.
     
    TheVirtualMunk likes this.
  24. PhamThiHang

    PhamThiHang

    Joined:
    Jan 5, 2019
    Posts:
    1
    Hello, anything update about blending between two timelines in one playabledirector ?
     
  25. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    A playable director can only play a single timeline. To blend between timelines, use two playable directors, and apply ease-in/out on first/last clips on the second timeline.
     
    PhamThiHang and ModLunar like this.
  26. ModLunar

    ModLunar

    Joined:
    Oct 16, 2016
    Posts:
    374
    @seant_unity ..Interesting! Thanks for the insight, I'll have to try that sometime if/when I happen to use playables again.
     
  27. ersagunkuruca

    ersagunkuruca

    Joined:
    Feb 26, 2021
    Posts:
    3
  28. Stacklucker

    Stacklucker

    Joined:
    Jan 23, 2015
    Posts:
    82
    @ersagunkuruca
    maybe not the answer you are looking for, but it is (and has been for some time) possible to blend between timelines, at least for certain tracks.
    We do this ourselves for our current game, by tweening the individual weights of say the AnimationPlayableOutput in a coroutine.

    Ideally Unity will come out with a native API for blending, but until then this is the only way I know of to achieve what you're probably looking for.

    If I have some time and there is interest for this I might write a tool for it, but I'm not sure I can make enough time for that right now.
     
  29. Windwalk_Rosco

    Windwalk_Rosco

    Joined:
    Aug 10, 2020
    Posts:
    20
    @Stacklucker would love to see that if you ever get around to it!
     
    Stacklucker likes this.
  30. RowDaBonk

    RowDaBonk

    Joined:
    Jul 19, 2012
    Posts:
    3
    @Stacklucker, I am currently working on such tool, but I haven't been able to weight the outputs with no luck. I'd love to see how you managed to do it!
     
  31. pwka

    pwka

    Joined:
    Sep 19, 2012
    Posts:
    49
    Any news on that? ;)
     
    rikimaru_tann likes this.
  32. Jrainstar

    Jrainstar

    Joined:
    Mar 5, 2022
    Posts:
    1
  33. Roeeyz233

    Roeeyz233

    Joined:
    Mar 12, 2023
    Posts:
    1
    Well, it's 2023 now. We didn't meet any related update in the past five years..
     
  34. Wipf

    Wipf

    Joined:
    Jan 17, 2017
    Posts:
    1
    Let's meet 2024. Any update on this?
     
    Ga2Z and vertyverty like this.