- Home /
Question by
Tryz · Apr 12, 2015 at 11:28 AM ·
c#animationblend tree
How do I set timeScale with Animation API?
I can create the blend tree and add animation clips (motions). However, setting the 'timeScale' or 'mirror' properties doesn't set the properties in the resulting blend tree.
Any thoughts?
// Create the blend tree. This is so bad, but apparently what we have to do or the blend
// tree vanishes after we run.
BlendTree lBlendTree;
AnimatorState lDeleteState = mAnimatorController.CreateBlendTreeInController("DELETE_ME", out lBlendTree);
lBlendTree.name = "WalkBlend";
lBlendTree.blendType = BlendTreeType.SimpleDirectional2D;
lBlendTree.blendParameter = "Input X";
lBlendTree.blendParameterY = "Input Y";
lBlendTree.AddChild(mForwardAnimation, new Vector2(0, 1));
lBlendTree.AddChild(mBackwardAnimation, new Vector2(0, -1));
lBlendTree.AddChild(mRightAnimation, new Vector2(1, 0));
lBlendTree.AddChild(mLeftAnimation, new Vector2(-1, 0));
lBlendTree.AddChild(mIdleAnimation, new Vector2(0, 0));
lBlendTree.children[2].timeScale = 1.25f;
lBlendTree.children[3].timeScale = 1.25f;
// Get rid of the dummy state we created to create the blend tree
lDeleteState.motion = null;
mAnimatorController.layers[mAnimatorLayer].stateMachine.RemoveState(lDeleteState);
// Create the actual state we want
AnimatorState lAnimationState = lMotionStateMachine.AddState("WalkBlend");
lAnimationState.motion = lBlendTree;
Thanks
Comment
I would also really like to know if there's a solution to this... (The reason it doesn't work is that BlendTree.children gives you a copy of the list, with no access to the original objects themselves)
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Problems with player movement animation 0 Answers
Blend Tree Animation Problem 1 Answer
Multiple Cars not working 1 Answer
Blend tree parameter 1 Answer