Greetings from a first time poster,
First, I did a cursory search for solution to this problem so I apologize in advance if this is a stupid question or if it has already been answered somewhere.
I am an animator working with a programmer on developing a 2D platformer with an orthographic camera. We are working on getting our player avatar up and running/moving horizontally on screen. We have been really impressed with Mecanim so far, but have run into a conundrum when using the Animation Layers and Body Masks.
I imported the players FBX file into Unity as a Humanoid and set up everything. We have basic animations like Idle, Running, Walking, and Jumping. We also have a “Melee Attack” animation where the avatar swings a sword. What I would like to do is to utilize that same Melee Attack animation for every time the avatar attacks, whether he is Idle, Running, Walking, or Jumping. This would prevent me from having to create a separate animation for each of those states.
Our initial approach was to create a separate Animation Layer and use a Body Mask for the upper body, so that we could activate the Melee Attack for the upper body of the avatar but keep the lower body in whatever state it was in. The problem is that the upper body seems to always be dependent on the hips. This creates issues when the hips are not facing the direction we want the player to attack (left or right). For example, in the Idle stance the players hips face about 50 degree towards the camera, so the player doesn’t swing the sword horizontally on screen, it swings towards the camera.
It would be nice if, when the Animation Layer with the Upper Body Mask was activated, it wasn’t dependent on the hips in the Base Animation Layer, but acted instead like IK or dependent on world space. I have tweaked and re-tweaked the import settings like “Root Transform Rotation” for the Animation Clips ad nauseum and cannot get it to behave as desired.
So my questions are: Are we approaching this correctly? Is this even possible? Am I going to have to create a completely separate Melee Attack animation for each state such as Running, Walking, Jumping, and Idle? Am I missing something simple and obvious?
Thanks for any feedback!