2
\$\begingroup\$

So I have two legacy FBX animations; Animation A and Animation B.

What I'm looking to do is to be able to fade from A to B regardless of the current frame A is on.

Using animation.CrossFade() will play A in reverse until it reaches frame 0, then play B forward.

What I'm looking to do is blend from the current frame of A to the end frame of B. Probably via some sort of lerp between the facial position in A and the facial position in the last frame of B.

Does anyone know how I might be able to accomplish this? Either via a built in function or potentially lerping of some sort?

EDIT: Does anyone perhaps know of a way to read bone positions of an animation at a certain frame? Perhaps if I could read that I could fake animations by doing Vector3 lerps.

\$\endgroup\$

2 Answers 2

0
+50
\$\begingroup\$

You need to make 'dummy' animations that are just the last frames of each animation, and blend between those.

The animation system will try to play an animation if it is not playing, so if you just want to blend between the last frames of two animations, you need the animations to be loops only containing the last frame.

\$\endgroup\$
1
  • \$\begingroup\$ This would only work for blending from the end frame of one animation to the end frame of another. However it did give me an idea for my final solution, so I'll give you the rep anyways, thanks a lot! \$\endgroup\$ Jun 22, 2014 at 19:08
0
\$\begingroup\$

So what I ended up doing was using AnimationUtility.GetAllCurves(clip) to cache animation curve data from each AnimationClip in the editor. Once you serialize this data you can build to whatever platform you want.

What you do is take the animation curve data for a given animation, and using the key.time and key.value Keyframe variables create a new AnimationClip using only the frame you want to blend from and a second AnimationClip using only the frame of another animation that you want too blend to.

You then use animation.AddClip(); on this temporary clip, then crossfade between the two. Giving you a seamless fade from any point of one animation to any point in another.

The code for this project is private. However, if anyone else having this problem needs further help or guidance feel free to contact me at [email protected]

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .