This is a video showing the bug,in a layer no base layer,When the blue line is interrupted, the character’s animation has a one-frame error. found in last build 2022.3.30
It looks like it is because you’re trying to use the Any State, which can be called from anywhere if the conditions match. Using the Any State is pretty loose and uncontrolled. Consider adding direct transitions and blend trees to get better results.
After test, I don’t think Any State is causing the problem,There will also be a 1frame error when the blue line of the base layer is interrupted.
after all test finally find the bug is: if you change clip on overrider in runtime when any transition is interrupted,it will broken animation
the solution is keep set trigger away from set clip
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestClipMount : MonoBehaviour {
public Animator Ani;
public AnimationClip Clip;
// Start is called before the first frame update
void Start() {
var origin = Ani.runtimeAnimatorController as AnimatorOverrideController;
AnimatorOverrideController instanceController = new AnimatorOverrideController(origin);
Ani.runtimeAnimatorController = instanceController;
}
private int m_comboIndex = 1;
// Update is called once per frame
void Update() {
if( Input.GetKeyDown(KeyCode.A) ) {
StartCoroutine(DoCombo());
}
}
private IEnumerator DoCombo() {
var controller = Ani.runtimeAnimatorController as AnimatorOverrideController;
var combo = ++m_comboIndex % 2 + 1;
controller["Combo" + combo] = Clip;
yield return null;
Ani.SetBool("Move", !Ani.GetBool("Move"));
Ani.SetInteger("Combo", combo);
Ani.SetTrigger("Attack");
//yield return null;
}
}