Search Unity

Making TPS: how to link weapon model to player model?

Discussion in 'Formats & External Tools' started by DaniilGalahow, Apr 9, 2015.

  1. DaniilGalahow

    DaniilGalahow

    Joined:
    Dec 2, 2013
    Posts:
    12
    Hello, community!
    I creating a shooter (mostly for self-education purposes), I create player model (in Blender, model is rigged and ready for animation) and a bunch of weapon models. Now I want to put a weapons to player hands. I.e., I want to create in player model some kind of pivot, from which a weapon can inherit position and rotation. How can I do this?
    (Sorry for possible stupid question, I didn't find an answer by search)
     
  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    If you know the game object from which the weapon needs to inherit the position and rotation, the simplest way to achieve it, is by making it a child of that game object and setting the local rotation and local position to zero.
     
  3. DaniilGalahow

    DaniilGalahow

    Joined:
    Dec 2, 2013
    Posts:
    12
    Thanks, Dantus.
    Could a part of model's mesh or rig be a separated game object, or I need to add a new mesh for this purpose?
     
  4. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    When you import the rigged model, you can select in the rig tab, whether you want to "Optimize Game Objects".
    http://docs.unity3d.com/Manual/FBXImporter-Rig.html

    If you optimize, all the bones won't be in the hierarchy anymore. However, you can specify individual bones that should still be there. Either don't optimize, or explicitly expose the bone you need. Like that you can use those bones to attach anything to them what you want.
     
    theANMATOR2b likes this.
  5. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,076
    Hi.
    Did you make a weapon mount bone, in the Players bones, in the palm of his hand?
    eg.
    http://i.imgur.com/eGUfz.png

    This technique is a great one to use.
    The weapon mount bone, is used to hold, rifles or swords, grenades etc. :D
    That's why it is pointed up like your thumb. ;)
     
  6. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    But will need to be masked if using humanoid rig and mocap animations. ;)