I’ve been trying to make a editor script that automatically assigns animations in a 2D blend tree. I have trouble setting the positions of the motions in the 2D blend tree.
Declaring the blend tree and adding children.
BlendTree blendTree;
AnimatorState grounded = controller.CreateBlendTreeInController ("Grounder", out blendTree);
blendTree.blendType = BlendTreeType.FreeformDirectional2D;
blendTree.blendParameter = "Turn";
blendTree.blendParameterY = "Speed";
blendTree.AddChild (idleAnim);
blendTree.AddChild (idleLeft);
blendTree.AddChild (idleRight);
blendTree.AddChild (walkAnim);
blendTree.AddChild (walkLeft);
blendTree.AddChild (walkRight);
This is where the problem is. I tried using this:
blendTree.children[0].position = new Vector2 (0f, 0f);
blendTree.children[1].position = new Vector2 (-1f, 0f);
blendTree.children[2].position = new Vector2 (1f, 0f);
blendTree.children[3].position = new Vector2 (0f, 1f);
blendTree.children[4].position = new Vector2 (-1f, 1f);
blendTree.children[5].position = new Vector2 (1f, 1f);
But When I ran the code the position of all the Child Motions was 0, 0.
Is there a solution to this problem ?
Thanks in advance.