Search Unity

Mecanim not showing proper animation imported from Blender.

Discussion in 'Animation' started by Turnspender, Oct 25, 2013.

  1. Turnspender

    Turnspender

    Joined:
    Jun 27, 2013
    Posts:
    12
    Hello. Using Blender, I modeled a man with a gun. Sometimes the gun has to be holstered, and sometimes has to be held in his right hand, so I made a bone for gun, made it a child of root bone, and added "Child of" bone constraints for both his right thigh and right hand bones.

    It was working fine until I tried to animate the character with Mecanim. Firstly, "Humanoid" importing did not work, because it made the gun move out of place. So I gave up that and tried Generic setting, but again encountered problems with blending tree and animation layer. Whenever my character takes "a pose between animation clips", my gun bone move away from my character's right hand and blended as independent bone. I hope the attached images make sense.

    Am I doing something Mecanim are not designed to do? If so, what is the alternative to create a character with a bone that switches its parent (or making character who can hold and holster his weapon)?
    I really hope not that I have to use Legacy...

    Sorry if my question is too vague or fundamental.

    $WS000066.JPG $WS000067.JPG Constraints and the gun bone.

    $WS000068.JPG $WS000069.JPG Looking up and down clips...
    $WS000070.JPG ... and somewhere between them. The gun moves out of the right hand!
     
  2. Pirs01

    Pirs01

    Joined:
    Sep 30, 2012
    Posts:
    389
    New to animations my self so don't take what I say too seriously.
    Generally Mecanim Humanoid animation is suppose to be humanoid and not a humanoid with gun. It expects certain amount of bones organized in certain way which in case of humanoid doesn't typically include gun bones.
    Have you configured your avatar? If you configure it so that gun bones are not included maybe that will help.

    Generally I don't think you want your gun being part of animation of character for a game. You want animation for human shooting a gun but the gun itself should be a different entity which you constraint to your shooting hand on run time with script or state machine. The reason being that you may want to put different guns in character hand or like you said you might want to put the gun in holster in which case gun should be constrained to hand in one situation but then to a heap in another.
     
  3. Turnspender

    Turnspender

    Joined:
    Jun 27, 2013
    Posts:
    12
    Thanks for reply Pirs01!

    As for avatar, yes I tried masking/unmasking the gun bone, but didn't work either way.

    So gun should be a different entity... yes, that makes sense. But honestly, I cannot think the way to create a character who properly hold and aim gun without a gun in modeling process. For now I 'm going to research this method before I dive in action unprepared.
     
  4. Pirs01

    Pirs01

    Joined:
    Sep 30, 2012
    Posts:
    389
    Just make the animation with the gun just like you did but just before exporting to Unity remove the gun. This way you can import your human and gun as separate entities and be sure they will work together just fine. Now, as to how to get them to work together inside Unity is something I didn't get to myself yet so I don't know what are the best practices.
    I might be doing that very thing today or tomorrow. If so I will share whatever I learn.
     
  5. Turnspender

    Turnspender

    Joined:
    Jun 27, 2013
    Posts:
    12
    Oh, yes! I think it works for me! I 'm really glad my efforts weren't wasted.

    Thanks Pirs01!
     
unityunity