- Home /
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 (https://docs.unity3d.com/Manual/Playables.html)
// 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
GetComponent<Animator>().Play(clipPlayable);
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?
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?
Answer by comtronic · Dec 05, 2016 at 03:08 PM
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.
Your answer
Follow this Question
Related Questions
Apply an animation from BVH or data stream to a humanoid character at runtime 2 Answers
Parenting generic weapon to Humanod breaks Humanoid's animation 1 Answer
Replace Avatar in Animator at runtime to create character configurator 0 Answers
Mecanim - Bone Target Matching = Whole object translation! 1 Answer