I have an animation and I modified some rotations of some bones in the animation at a certain frame. What I want to do is how to make the animation in the next couple of frames interpolate smoothly so that the changes I made looks smooth?
Like for example, if I have an animation of a game object, and in frame number 100 it rotated 90 degree in the x-direction. So now frame 100 has a modified rotation angle of the object, but frame 101 has the original animation. I want to smooth the rotation so that the transition of the object from the modified frame back to the original animation looks smooth.
Maybe store your manually set new position, then lerp between the animation and the manual position.
Something likeā¦
void LateUpdate () {
float transitionStartTime = 2.0f;
float transitionDuration = 4.0f;
Quaternion manualRotation = Quaternion.Euler (90, 0, 0);
Quaternion animationRotation = jointToRotate.transform.localRotation;
float lerp = 1 - Mathf.Clamp01((Time.time - transitionStartTime) / transitionDuration);
jointToRotate.transform.localRotation = Quaternion.Lerp (animationRotation, manualRotation, lerp);
}
Assuming the animation has keyframes at later frames (say you wanted it to be back to the original animation by frame 106), you might be able to just delete the intermediate keyframes (e.g. 101-105) in the Animation window. You may need to edit the tangents of the keyframes at the ends to get the curve the way you want for the transition.