I'm trying to drive the animation of a Unity3D Mecanim rig based on live data from a Leap Motion Controller. I have 2 layers masking out everything but the hands in a Mecamim Human rig, on top of a base layer driving the rest of the rig. Both "hand layers" reference the same Animation Clip.
When I set the curve of a property in the clip using:
leftClip.SetCurve ("", typeof(Animator), "LeftHand.Index.1 Stretched", new AnimationCurve (new Keyframe (0, CurrentPosition), new Keyframe (0.5f, CurrentPosition)));
All currently playing states in the animator reset their playback creating a rather unhelpful jittery effect.
I'm getting a reference to the clip via the animator's runtimeAnimatorController
property so I've got a reference to the runtime instance of the clip and not the asset.
I'd like to avoid going the route of overriding Mecanim in LateUpdate()
due to the probability of race conditions with other LateUpdate-ing code and wanting to take advantage of Mecanim's animation tools in the rest of our pipeline.
Is there a method by which I can set a property in an animation clip at runtime without resetting the state playback? Specifically I need to set the Mecanim Humanoid Avatar muscle values.