Search Unity

Maintaining state between Timeline and Animator Controller

Discussion in 'Timeline' started by kogtech7, Sep 10, 2019.

  1. kogtech7

    kogtech7

    Joined:
    Jul 31, 2017
    Posts:
    10
    Is there a simple way to maintain the final state of Timeline as default? Say I animate a character with Timeline during a cutscene, ending in a fancy pose. Now game logic takes over, and I want to play a head animation with Animator.Play(state) while maintaining the rest of the pose. Each body part is on its own layer.

    - If I don't dispose of Timeline's playable graph, it has precedence over Animator.Play(state).
    - If I dispose of Timeline's playable graph, the character reverts to the default state and loses their pose.
    - Timeline works with clips (AnimationClipPlayable) while Animator.Play works with states, so I can't immediately have the Animator play what the Timeline ended on.

    I could bake layer index, state names, etc. into my Timeline metadata to get around this, dynamically tuning the weight of desired layers to zero... but it's very convoluted. Is there is a simpler way to set state from Timeline the way animator.WriteDefaultValues() does?
     
  2. kogtech7

    kogtech7

    Joined:
    Jul 31, 2017
    Posts:
    10
    Managed to get by this. Even though AnimationLayerMixerPlayer only needs masks, we store references to Playables and layer indices separately. Toggling the appropriate weights to zero in tandem with Animator.Play.

    A manual way to set defaults of an animated body would still be nice, considering it's a toggle option on states. Perhaps as a function of an animator (factoring all inputs), or an AnimationPlayableOutput.
     
  3. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Agreed - a write default on exit would be a nice addition. Write defaults during timeline evaluation, in particular during preview, can be problematic, mainly because it introduces dependency on previous frames. There are other related discussions/issues where adjacent clips that don't animate the same things cause unexpected behaviour (since the un-animated values revert to default). The suggested approach there right now is to use layers.

    2019.2 timeline actually uses a animation clip of 'defaults' that evaluates before timeline to get around some of these issues (because scene defaults and animator defaults aren't necessarily the same), but we should definitely come up with better solutions for a bunch of these related use cases.