public void Bake(string targetAnimation) { AnimationData targetAnimationData = GetAnimationData(targetAnimation); //The overrite machine. Creates an overrideController, replace its core animations and restate it back in if (targetAnimationData == null || targetAnimationData.clip == null) { return; } currentAnimationData = targetAnimationData; AnimatorOverrideController overrideController = new AnimatorOverrideController(); float newAnimatorSpeed = Mathf.Abs(targetAnimationData.speed); overrideController.runtimeAnimatorController = controller1; overrideController["State1"] = targetAnimationData.clip; animator.runtimeAnimatorController = overrideController; animator.Bake("State1"); }