I have a simple game I'm working on to help me learn unity3d. In my Start() function, I've used the following code to set up my animations.
walkAnimation = animation["Walk"];
walkAnimation.layer = 1;
walkAnimation.blendMode = AnimationBlendMode.Additive;
walkAnimation.enabled = true;
walkAnimation.wrapMode = WrapMode.Loop;
walkBackwardsAnimation = animation["WalkBackwards"];
walkBackwardsAnimation.layer = 0;
walkBackwardsAnimation.blendMode = AnimationBlendMode.Additive;
walkBackwardsAnimation.enabled = true;
walkBackwardsAnimation.wrapMode = WrapMode.Loop;
TurnLeftAnimation = animation["TurnLeft"];
TurnLeftAnimation.layer = 1;
TurnLeftAnimation.blendMode = AnimationBlendMode.Additive;
TurnLeftAnimation.enabled = true;
TurnLeftAnimation.wrapMode = WrapMode.Loop;
TurnRightAnimation = animation["TurnRight"];
TurnRightAnimation.layer = 1;
TurnRightAnimation.blendMode = AnimationBlendMode.Additive;
TurnRightAnimation.enabled = true;
TurnRightAnimation.wrapMode = WrapMode.Loop;
Each of them are declared before start like this
public AnimationState walkAnimation;
and I call them depending on the values of the control's axis, like such;
if(Mathf.Abs(Input.GetAxis("Rotate Player")) > 0){
if (Input.GetAxis("Rotate Player") > 0){
animation.CrossFade(TurnRightAnimation.name, 0.2f);
}
The problem is, The animations don't play, and when I turn while moving my character deforms gruesomely, his arms rise above his head and into his body, other parts grow, etc
I've been battling with mixing animations for the last two weeks, but I'm determined to get it right. If you know anything about this problem please don't hesitate to tell me what it might be. I created the model myself as well, all animations are on a single mesh, and I've tried to make the different animations affect different bones.