Search Unity

3D model animation to works properly with weapons

Discussion in 'Animation' started by Ryniu, Mar 9, 2014.

  1. Ryniu

    Ryniu

    Joined:
    Feb 23, 2014
    Posts:
    2
    In advance sorry for my english.

    In most of FPS tutorial there are only hands with the gun instead of 3D model. The guns in their animations have hands included.

    I want a full character in my game, but how should I prepare it for this?

    I have a model and simply walk/run animations, but I don't know how do this things with weapons.

    Should I create a my 3D character animations with every guns in Blender ? I think it's not good solution because in every gun model it would have a character model included.
    This would require more disk space. Maybe it is possible, not including full character's model into animaitons, but just mesh, or sth like that?

    Or maybe other solution?
     
  2. Alf203

    Alf203

    Joined:
    Dec 7, 2012
    Posts:
    461
    Character is one skinned mesh, gun is another. They are not part of the same, but each are their own mesh. Gun will be child of the character (child of a hand bone would makes sense). Animate both character and gun separately and in Unity just instantiate the gun prefab you want to use on his bone. Play animation on character that fits the gun he is using. You could also use IK instead of animation to modify the character hands for a specific gun without having to have animations for each type of gun.
     
  3. Ryniu

    Ryniu

    Joined:
    Feb 23, 2014
    Posts:
    2
    Thanks for fast reply :) I heard about IK and a little used it in Blender for animate legs. I need read more about IK in Unity.

    It means that i can animate legs only in Blender, and then move hands in Unity ? Is it work in free version of Unity ?

    It might be simpler to do in blender. But one more thing, e.g. If I will do it in blender, need I create separately walk with rifle, run with rifle, walk with handgun, etc. or just make a walk/run animations in T-pose and after that, rifle/handgun while legs are not moving ? I think it would be possible using layers in Animator component.
     
    Last edited: Mar 10, 2014
  4. Alf203

    Alf203

    Joined:
    Dec 7, 2012
    Posts:
    461
    I think the built-in IK in Unity is pro only… but check the asset store for Final IK, its an amazing plugin and works on free, be sure to check it out.

    With IK it means it will modify the hand position inside Unity to match with the gun he is holding, so that he holds the gun right.

    That being said, if you don't want to use IK, you can do it all with animations and you might not need walk with rifle and run with rifle, walk with handgun etc… Because you can combine the hands with another animation of the legs and body for example.

    If you do that, then yes you should probably use the layers with the animator. It will make your life easier. You can use avatar mask if you need and have the legs and body in the main layer and arms in a subsequent layer or something like that. One way to do it would be so that in the second layer you have the animated hands and arms and you'd have states like (empty hands)(rifle hands)(handgun hands). Then in the main layer your character could run, walk idle, crouch, etc... while in the second layer his hands could be holding the rifle or the handgun depending on the state.

    If you don't end up using Final IK for holding the guns and decide to go the animation way, you could still use the plugin for the aiming if you wish.
     
    Last edited: Mar 10, 2014
  5. Mufan

    Mufan

    Joined:
    Aug 11, 2013
    Posts:
    15
    Hi!

    I have the related question. Would you be so kind to explain or advise me?
    So, I have the human (Skin) with bones in 3ds max. Also, I have the weapon (Editable Poly) in the same file.

    The 0 frame contains the TPose of human and a weapon in some position.
    Then I animate them together (from the 1st to Nth frames): human with bones weapon with itself tranforms. So, I get the animation - human with weapon in his hands.

    I export all objects in one FBX, then import to Unity. Select "Humanoid", click Apply and the TPose configures automatically. Then I set the animation's frames, and the human's animation looks ok.
    But the weapon's animation does not. It looks like the weapon's position during the animation is equal to weapon's position in the 0 frame. But rotation
    looks correct. So my human waves empty hands and near by the weapon is rotating in the air.

    If I choose the Generic type it looks all ok. But what's wrong with Humanoid? :(

    Thanks!
     
  6. Alf203

    Alf203

    Joined:
    Dec 7, 2012
    Posts:
    461
    The weapon is a child of which bone in your character?

    Please check if your root motion is on or off.