I've made my player model in Blender3D - it has one mesh and rigibody. I've created walking and punching animation which both work good when played apart. But whenever I try to walk and punch it cuts the punching animation in half. What am I doing wrong, could anybody help me with that? Thanks in advance.
More info needed. Is this in Unity? If so look into avatar mask. If in blender possibly posting in a blender forum may give you better chance at feedback.
Yeah. It's all in Unity. The animations work fine in Blender since they are played apart. Here's my code for the animations: Code (JavaScript): //Walking animation if(controller.velocity.magnitude >= 0 && (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.D)) && !Input.GetKey(KeyCode.LeftShift)) { animation.Blend("Walk"); animation["Walk"].wrapMode = WrapMode.Loop; animation["Walk"].speed = 1; } //Punching animation if((hasMelee == true || hasPickaxe == true || hasAxe == true) && canSwing == true && playerGUI.staminaBarDisplay >= 0.1) { if(Input.GetMouseButtonDown(0) && player.GetComponent(CraftingController).isBuilding == false) { playerGUI.staminaBarDisplay -= 0.1; animation.CrossFade("Punch"); isSwinging = true; canSwing = false; } } The thing is that when I am walking and I click the punching button it tries to punch but cuts the animation in half. He's only raising his hand a little instead of punching. How do I solve this? Is there any specific script for this or do I need to have two halves of body apart - lower and upper? Also, where do I find avatar mask? Seems like i don't have any of those on my player model, maybe it's because my model is marked as legacy.
I don't recall if legacy has any limb masking capability so I defer to others to offer a solution using legacy. I don't see why it's only playing half the punch, I'm not a code guy. If you switched your rig from legacy to humanoid and used the avatar mask - I think you'd find a solution to your problem. This will get you running with avatar mask quickly. That and this.
take a look at http://docs.unity3d.com/ScriptReference/AnimationState.RemoveMixingTransform.html http://docs.unity3d.com/ScriptReference/AnimationState.AddMixingTransform.html you will need to remove all the upper body transfrom from the walk animation state and remove all the lower body transform from the punch animation state. This is for Mecanim only, it cannot be used with the legacy animation system.
Thank you very much! If I were to use avatar mask would I need to do the same? Also if I created my model with animations in Blender, can I use other type of animation than legacy?
To use the avatar mask you would need to switch your rig type in Unity from legacy to humanoid. Then proceed to setup an avatar and avatar mask as described in the manual. But instead of masking the upper and lower body as with the legacy system, you'd mask the entire body except the arm that is animated. So the character would perform the walk animation on his entire body except for the arm that is punching. The animation software has no outcome on animation types available in Unity.