Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question how do you cross fade play a playable the easy way

Discussion in 'Timeline' started by laurentlavigne, Jan 16, 2021.

  1. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,002
    timeline has only Play(playable)
    no CrossFadePlay(playable)
    so
    how do i crossfade play a playable, interrupting a current timeline play?

    the easy way
     
  2. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    This may do part of what you want.

    I wish we had better built-in support for mixing, but at the moment, crossfading has a few obstacles:
    • Animation tracks override the weight of their outputs every frame, making it tricky to fade them out.
    • Most user defined tracks (ScriptPlayableOutput) have no real outputs, and they completely bypass or ignore the weights by directly writing to components, making it impossible to crossfade.
    • Setting up bindings for multiple Timelines isn't straightforward.
     
  3. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,002
    What's the URL?
     
  4. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,002
    What's a weight? I don't see any weight in the timeline.


    Most user defined tracks (ScriptPlayableOutput) have no real outputs, and they completely bypass or ignore the weights by directly writing to components, making it impossible to crossfade.

    I don't understand that either, could you explain how this differs from the way I do things?
    I plop animation on a timeline, record the root's position and rotation, maybe add a few more animations with the record button.
    upload_2021-1-18_17-29-15.png



    Setting up bindings for multiple Timelines isn't straightforward.

    What is "binding"?

    Look at ANimancer lite on the asset store, it apparently does timeline xfading, tell me what you think of this solution.
     
  5. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    Playable graphs are what Timeline is built on. Playable Graphs have PlayableOutputs.
    An AnimationTrack is bound to an Animator through an AnimationPlayableOutput, and each output has a weight, which defines how much it overrides other, lower priority outputs on the Animator.

    To Crossfade between Timelines, you must lower the weight of the first Timeline on all its outputs, and increase the weight of the new Timeline on all its outputs.

    Well you are only using a subset of what Timeline can do. The Animation Track is only one of many tracks, both built-in and user-made.

    User-made tracks are hard to cross-fade, because they lack any proper mechanics to blend multiple sources of data. There are more details, but they are not that important in this context. Essentially, if we were going to offer a Crossfade mechanic, it would only work in very limited cases, which is not good enough.

    Bindings are the objects that you put in the boxes on the track headers. "outfit mirror (Animator)" in your case. These are not stored in the asset (because assets cannot refer to scene objects), they are stored in the PlayableDirector.

    Crossfading between Timelines requires having the bindings for both the new Timeline and the previous Timeline, which is extremely unwieldy.


    From a cursory search of the documentation, it doesn't mention Timeline, only Animation Clips. Blending single sources of Animation is way simpler than blending multiple audio/animation/script sources that may or may not target the same number of objects, or the same objects altogether.
     
    laurentlavigne likes this.
  6. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,002
    Got it, thanks for the run down.

    You mean require binding to match in both timelines? This is to be expected : xfade between a UI and a character has no meaning.

    It looks like an API problem: crossfade only works if the user adds support for blending. It doesn't look like such Method exist in PlayableBehaviour but maybe something like
    BlendFrame(Playable playable, FrameData info, object[] playerDatas)
    .