Can I create a humanoid animation through scripting at runtime?

I have a script that creates an AnimationClip and sets its curves (based on mocap data obtained at runtime). I was able to use it with no problem with a legacy Animation component on character that I created that has the same structure as the mocap data. Now I want to retarget it to a character using the Animator component that’s been rigged with a humanoid avatar.

I tried something like this that I found in the Unity Manual (Unity - Manual: Playables API)

// Generate a clip on the fly
AnimationClip clip = wrnch.GenerateClipFromMocap();

// Wrap the clip in a playable
var clipPlayable = AnimationClipPlayable.Create(clip);
// Bind the playable to the player

But it doesn’t seem to animate the character at all. As far as I know, I haven’t told Unity how to map my animation clip to a humanoid, so maybe that’s why it doesn’t work, but I haven’t found anything in the docs or forums on how to accomplish this. Is what I’m trying to do even possible?

I’m also very interested in this and I’ve scanned the internet for solutions without success. I think the only solution would be to reverse engineer the codebase of animations in Unity.

The only solution so far is to export the animation to a 3d format (3ds or maya) and then import it back to Unity.

this would be great, we need to record animations from mocap and translate at runtime to humanoid animation clips to be applied to any generic avatar which is already set to work with humanoid mecanim animations, there is no documentation about it at least so far I didn’t find any.

any thoughts or ideas?