- Home /
Blending two animations in layer during runtime
Dear everyone,
I have been trying to blend two animations in one layer so that half of the first animation is used and half of the second. The logical solution to this problem would be to use a blend tree. The problem is I have 12 animations per layer and I want combinations of 2 animations for all of them. This would result in 144 different blend trees which is overkill in my opinion. I have been trying to modify the blend trees during runtime with help of this thread: https://answers.unity.com/questions/1401279/how-can-i-access-blend-tree-in-animator-controller.html
However, unity does not allow this and it breaks the animator. I was wondering if there is a way to blend two animations during runtime. Thank you in advance!
ps: The way I tried editing the blend tree
anim = GetComponent<Animator>();
ac = (AnimatorController)anim.runtimeAnimatorController;
BlendTree tree = (BlendTree)getMotionByName("BlendTree");
tree.AddChild(getMotionByName("anim1"));
tree.AddChild(getMotionByName("anim2"));
tree.useAutomaticThresholds = true;