- Home /
Question by
sbsmith · Aug 18, 2016 at 01:05 AM ·
animationcharactercontrollermechanimskinnedmeshrenderer
What are the best practices for syncing/duplicating/instancing complex skinned animations?
Are there any best practices for syncing (duplicating, copying, or instancing) complex blended animations with transition blends?
I have a character controller with an animator driving a "master" character. It has several instances at various offsets that mimic it.
With simple state machines, Animator.Play works fine.
for (int iLayer = 0; iLayer < masterAnimator.layerCount; ++iLayer )
{
AnimatorStateInfo layerInfo = masterAnimator.getCurrentAnimatorStateInfo(iLayer);
for (int iInstance = 0; iInstance < this.Instances.Count; ++iInstance)
{
VisualInstance inst = this.Instances[iInstance];
Animator slave = inst.gameObject.GetComponent<Animator>();
slave.Play(layerInfo.fullPathHash, iLayer, layerInfo.normalizedTime);
}
}
If we're using Blend Trees, we can sync the parameters with
AnimatorControllerParameter parameter = parameters[iParameter];
switch (parameter.type)
{
case AnimatorControllerParameterType.Float:
slave.SetFloat(parameter.nameHash, masterAnimator.GetFloat(parameter.nameHash));
However, I'm stuck when it comes to transitions.
Instead of the above method, should I just be using a master SkinnedMeshRenderer and then BakeMesh to create a static mesh to use for that frame of all my slave instances? That method works, but is it the most optimal?
Thanks!
Comment