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:
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.
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:
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.
I found one thing interested: there is a tips when the timeline animation is playing
So I found curves change the root transform:
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?
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:
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.
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.
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?
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.
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.
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?
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.
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.