Search Unity

Correct way to ease from Animator into Timeline?

Discussion in 'Timeline' started by mrtenda, May 14, 2019.

  1. mrtenda

    mrtenda

    Joined:
    Jun 6, 2017
    Posts:
    73
    In order to seamlessly blend gameplay and cutscenes, we need to smoothly transition from a character's animator playing its animation to the timeline playing a different animation on that same character.

    We also have the restriction that we need to manually update the timeline using Evaluate() in order to play the timeline perfectly in sync with the game's music.

    In 2018.2, our solution was to give the animation clip on the timeline an ease in duration and set pre-extrapolate to "None". Then, we would play the timeline by manually calling Evaluate() on the PlayableDirector every LateUpdate. This worked perfectly for us.

    However, this technique no longer works in 2019.1. When I try this in 2019.1, instead of easing from the animator's animation to the timeline's animation, the timeline's animation just immediately takes effect without any easing.

    Is this change in behavior from 2018.2 to 2019.1 intentional? If so, what would be the recommended alternative way to do this in 2019.1?

    Videos
    - Expected behavior (2018.2.13f1):

    - Unexpected behavior (2019.1.2f1):
     
    Last edited: May 14, 2019
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    I am going to guess this is due to the root motion changes that were introduced in 2018.3. Try setting the track to use as it's track offset mode Scene Offsets, which will tell timeline to start playing from the current position/rotation.
     
  3. mrtenda

    mrtenda

    Joined:
    Jun 6, 2017
    Posts:
    73
    If I change it to Scene Offsets, the character's animation still doesn't ease properly from idling to walking.

    Also, just to make sure I'm being perfectly clear, the issue isn't only the root motion. It's also the animation itself. If you look at the character's arms in the 2018.2 video vs the 2019.1 video you can really see the difference.

    Video (2019.1 with Scene Offsets):
     
    Last edited: May 14, 2019
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Ok, that's definitely more obvious in the second post :)

    How are you animating the character before the timeline is played? It is an animator controller? It looks like timeline is blending, but from the (wrong) default pose.
     
  5. mrtenda

    mrtenda

    Joined:
    Jun 6, 2017
    Posts:
    73
    Yes, it's an animator controller.
     
  6. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Is there anyway you could send the sample? (DM or by filing a bug). This should work the same, but there are a staggering number of configurations of curve types, root motion, generic/humanoid, etc, and I can't say for certain why that behaviour changed, or how to fix it without a bit of investigation.
     
  7. mrtenda

    mrtenda

    Joined:
    Jun 6, 2017
    Posts:
    73
    I've filed a bug with a sample unity project attached (Case 1154541).
     
  8. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    @mrtenda Thanks for filing, I see what's happening now. The clue was there in your post, I should have paid more attention to:

    We also have the restriction that we need to manually update the timeline using Evaluate() in order to play the timeline perfectly in sync with the game's music.

    Anyway, the way animation tracks are blended to other systems did change in 2018.3. The blend with the controller (or other timelines) work if they are all evaluated together. So calling evaluate() is causing timeline to blend with the default pose - and in this case, the default pose is the pose from when the timeline started, not the current default pose.

    The animator writing the default pose should do the right thing here, but it isn't. Timeline is using the 'wrong' default pose to blend to. That looks like a valid bug you've uncovered.

    As a fix, you can change the way you are evaluating timeline manually. Instead of force evaluating in LateUpdate(), set the speed of the timeline to 0, and just set the time in update.

    e.g.
    Code (CSharp):
    1.   void Update()
    2.     {
    3.         if (PlayableDirector && PlayableDirector.playableGraph.IsValid())
    4.         {
    5.             PlayableDirector.playableGraph.GetRootPlayable(0).SetSpeed(0);
    6.             PlayableDirector.time = Time.time;
    7.         }      
    8.     }
    That will cause the timeline to evaluate with the controller. This is also more efficient that forcing an evaluate.





     
  9. mrtenda

    mrtenda

    Joined:
    Jun 6, 2017
    Posts:
    73
    That fix seems to work! Thank you very very much!!
     
    MitchStan and seant_unity like this.
  10. goricherririri

    goricherririri

    Joined:
    Aug 3, 2018
    Posts:
    1
    is this problem has been resolved in 2021?