Search Unity

Resolved How could I blend animation from timeline to animator controller?

Discussion in 'Timeline' started by Leozzyzheng, Dec 15, 2020.

  1. Leozzyzheng

    Leozzyzheng

    Joined:
    Mar 8, 2019
    Posts:
    16
    I'm using Timeline to create skills and it works nicely in most cases expect the animation.

    I can't find a way to blend the animation from the timeline to my normal animator controller after the timeline is finished. I have tried to create the ease out duration to blend to scene according to the documentation but it gives me strange behaviour:
    upload_2020-12-15_19-13-35.png
    the GameObject's position and rotation will move to Vector3.zero during the ease out no matter where I put my GameObject.

    My Unity version is 2019.4.6f1

    I think I have seen a lot of threads related to it, but they may not same problem to me, so I create a new thread to ask the similar question.
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    In edit mode the animator controller doesn't run, so it will only blend out to the animator controller in playmode.

    If the behavior is unchanged in playmode, then does your animator use root motion? If it doesn't, that might be the issue.
     
  3. Leozzyzheng

    Leozzyzheng

    Joined:
    Mar 8, 2019
    Posts:
    16
    I use playmode.

    In order to make it clear, I use a simple animation clip named RockMan_Jump_Attack, it is just a .anim file and has no mostion attached to it:
    upload_2020-12-16_9-17-31.png
    But I still check the Bake Into Pose to make sure it won't change my GameObject's position.
    Then my animator has also unchecked the Apply Root Motion. So there shouldn't be any root motions here right?
    But my GameObject still move back to zero position during ease out duration and stay on the zero position after timeline finished.
     
    Last edited: Dec 16, 2020
  4. Leozzyzheng

    Leozzyzheng

    Joined:
    Mar 8, 2019
    Posts:
    16
    I found one thing interested: there is a tips when the timeline animation is playing
    upload_2020-12-16_9-28-17.png
    So I found curves change the root transform:
    upload_2020-12-16_9-28-55.png
    If I remove those curves, then the strange behaviour won't happen any more.
    But If I understand it correctly, those curves are used to modify root not GameObject itself, why it will affect my GameObject's position when using the ease out duration?
     
  5. Leozzyzheng

    Leozzyzheng

    Joined:
    Mar 8, 2019
    Posts:
    16
    Another thing I found is if I removed the curves of Animator.Root, then the options for Root Transform in inspector are gone, I can't see checkbox like Bake Into Pose any more like this:
    upload_2020-12-16_9-41-52.png

    According to documentation here: The Root Transform is a projection on the Y plane of the Body Transform and is computed at runtime.

    In my image, it should be something at runtime and won't be the curves inside the animation clips, the behaviour from inspector shows me the Root Transform is rely on those curves of Animator.Root? I'm little confused about how animator thinks the Root Transform should be, it is directly related to what gives me the root motion so I also ask it here.
     
  6. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Root motion means it will apply the delta of the current animation root curves to the actual root transform, instead of writing an absolute value. By baking it into the pose, and not having root motion checked, it means the animation is actually writing the root transform value exactly as it is in defined in the curves (Root Q and Root Y), not accumulating it.

    Which explains why the character is popping back when the timeline finishes.

    And when the animator writes one channel of position or rotation, it writes all 3.

    I hope that makes it a bit clearer.
     
  7. Leozzyzheng

    Leozzyzheng

    Joined:
    Mar 8, 2019
    Posts:
    16
    Thanks for your explaination.

    My hierarchy like this:
    GameObject with animator component
    Root bone
    bones​
    MeshRenderer​

    In my design, I need move the character by other ways cause the same skill animation may have different move distance and height, so don't want animation to move the character.

    With root motion unchecked,
    If I uncheck the bake into pose, then GameObject will move by animation.
    if I check the bake into pose, the animation will move Root bone won't move GameObject, but in ease out duration, it will move the GameObject's position to (0,0,0).

    I think the ease out duration might have an issue, it should move model's position not GameObject itself right?
     
  8. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    That makes more sense. Thanks for clarifying.

    So, what I think is happening is because timeline always uses root motion it writes to GameObject, not Root bone. By easing out, timeline is blending out the gameObject position to it's default value (which is 0,0,0).

    You might be able to get around that by placing a signal before the ease-out which calls Animator.WriteDefaultValues(). That should make the timeline blend to the current value. If the ease is still animating the root, you may need to call Animator.WriteDefaultValues() each frame (through script or a custom clip). Note that I am speculating, and have not verified this....so your mileage may vary.
     
  9. Leozzyzheng

    Leozzyzheng

    Joined:
    Mar 8, 2019
    Posts:
    16
    That expain what I see, thanks.

    But why there is no way to disable the root motion apply to GameObject just like animator component? I think it is widely used for skill animation cause they all need to modify the root motion for the same one animation clip.
     
  10. Leozzyzheng

    Leozzyzheng

    Joined:
    Mar 8, 2019
    Posts:
    16
    Another problem is cause timeline always apply root motion, so I can't move my character when the timeline animation is playing, call WriteDefaultValues each frame would help?
     
  11. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    No, it wouldn't help. You can move the character in LateUpdate(). The problem is timeline is writing the root, but that occurs between Update() and LateUpdate().

    Another option is to use OnAnimatorMove() which allows you to override the writing of root motion, including from timeline.
     
    Leozzyzheng likes this.
  12. Leozzyzheng

    Leozzyzheng

    Joined:
    Mar 8, 2019
    Posts:
    16
    Declare an empty OnAnimatorMove works like a charm! It allows me to prevent timeline from applying any root motion to my GameObject and timeline animation blend to my controller's current animation very smoothly.

    Thanks for your very detail explaination and great help!

    BTW, I hope there will be a documentation about this special behaviour of root motion from timeline animation, that might help many other people like me to create smooth skill animation in timeline.
     
    Pourya-MDP, dudleyhk and seant_unity like this.