Hello! =)
I want to make an advanced animation system for our game that uses Animator as a base and Playables API for additional needs (for combo attacks, some complex interactions, etc.). Basically, I want to use Animator, and at the same time, I want more low-level control.
When mixing AnimatorControllerPlayable and AnimationClipPlayable with AnimationLayerMixerPlayable, the animation looks crooked:

In all three cases, I use the following Avatar Mask:
Code, which is used for the second (middle) character:
using UnityEngine;
using UnityEngine.Animations;
using UnityEngine.Playables;
public class SetupPlayables : MonoBehaviour
{
[SerializeField]
private Animator _animator;
[SerializeField]
private AnimationClip _clip;
[SerializeField]
private AvatarMask _mask;
[SerializeField]
private bool _applyFootIk = false;
[SerializeField]
private bool _applyPlayableIk = false;
[SerializeField, Range(0, 1)]
private float weight1 = 1;
[SerializeField, Range(0, 1)]
private float weight2 = 1;
private AnimationLayerMixerPlayable _mixerPlayable;
private void Start()
{
PlayableGraph playableGraph = PlayableGraph.Create(name + " (Custom)");
AnimationPlayableOutput playableOutput = AnimationPlayableOutput.Create(playableGraph, "Animation", _animator);
_mixerPlayable = AnimationLayerMixerPlayable.Create(playableGraph, 2);
_mixerPlayable.SetLayerMaskFromAvatarMask(1, _mask);
playableOutput.SetSourcePlayable(_mixerPlayable);
AnimatorControllerPlayable controllerPlayable =
AnimatorControllerPlayable.Create(playableGraph, _animator.runtimeAnimatorController);
playableGraph.Connect(controllerPlayable, 0, _mixerPlayable, 0);
_animator.runtimeAnimatorController = null;
AnimationClipPlayable clipPlayable = AnimationClipPlayable.Create(playableGraph, _clip);
clipPlayable.SetApplyFootIK(_applyFootIk);
clipPlayable.SetApplyPlayableIK(_applyPlayableIk);
playableGraph.Connect(clipPlayable, 0, _mixerPlayable, 1);
playableGraph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
playableGraph.Play();
}
private void Update()
{
_mixerPlayable.SetInputWeight(0, weight1);
_mixerPlayable.SetInputWeight(1, weight2);
}
}
This is what the PlayableGraph looks like for the second (middle) character:
I also prepared a project so that I could get into what was going on and experiment:
https://github.com/Bodix/Animancer-Layers-Bug
Why it contains Animancer It all started when I installed Animancer. The main killer feature of this asset for me is HybridAnimancerComponent: it allows to mix the work of RuntimeAnimatorController and animations from the code. It was when working with Animancer that I noticed this bug. I wrote the issue to the developer of the plugin, he said it was a Playables API bug. I decided to double-check and it really turned out to be true.
If you have any idea why this is happening, I would be VERY grateful.

