- Home /
The question is answered, right answer was accepted
Switching weapons animation with mecanim?
Let's assume I have character with two weapons. One weapon is on his back and the one he is using is on his hand. Then I press key and my character should switch weapons with animation. Also this animation should only affect his upper body so legs can keep running or standing or whatever they were doing.
The question is can I achieve this with mecanim?
Answer by JesHal · Feb 06, 2013 at 09:30 PM
This can be achieved by using avatar body mask.
At the end of this tutorial Unity 4.0 - Mecanim Animation Tutorial you will find out how to use body masks.
Answer by Max_Bol · Jun 05, 2015 at 07:32 PM
Just an additional note (since this is one of the first link that appear on Google when searching for Unity Humanoid weapon).
To make "stick" the weapons to the hand and to the back while using the humanoid animation type would be to expose the related bones to which you want the weapons be hold to.
For example, the hand that hold the weapon's handle with the trigger should have its bone exposed (if you're using the Optimized Game Object option for humanoids) this will allow the GameObject to have only the exposed bones shown in its children. (A lot more simple than searching through all the bones children to find the right one.) You could also expose the Torso related bone. That way, through a series of simple scripts steps you could animate the body and change the parenting of the weapons based on wherever you want the weapon to be hold.
Follow this Question
Related Questions
How to edit a Mecanim animation for your character? 1 Answer
Why do legacy & humanoid animations look different on the same character? 1 Answer
How do I replace parts of an animated character? 0 Answers
Facial Animation inconsistancy in Mecanim 0 Answers
Is there a Mecanim callback for, "Where X bone would be if IK was off"? 0 Answers