AnimationCurve inTangent/outTangent

Hello,

I’m working on animation mirroring system. (e.g. character waves with his right hand, but I want to automatically create an opposite animation where he waves by his left hand.).

What I do, is go through all the curves and flip their values accordingly(depending on mirroring axis, and bone pairs). However, I’m not sure what to do with inTangent and outTangent values of the curves?

Setting them to zero, and my animation doesn’t look right. Doing curve.SmoothTangents with weight=1, creates “okay” tangents. That is, the animation curve is very similar to the original one, but hardly the same. (I’ve tried setting the weight to 0, 0.5, and 2, and those look pretty bad)

I want to know how to calculate those tangents? The Unity obviously calculates them during import somehow.

Nobody knows?

What I think I know: when doing transformations, Unity never sees vectors and quaternions as a whole. It only sees their lone x, y, z, w components. Those two tangents somehow help animate those components so it looks like we’re animating the entire vector or quaternion(SLERPing for example, without tangents the curve of each of the x, y, z, w would be linear from value A to B to C, etc.).

Even if you don’t know Unity specifics, maybe you could point me in the right way, to study how are those curves generated?