Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Attaching a weapon to the player and animating

Discussion in 'Editor & General Support' started by RoXCoder, Mar 20, 2012.

  1. RoXCoder

    RoXCoder

    Joined:
    Mar 3, 2012
    Posts:
    98
    Hi,

    Im having hardtime understanding the concept of FPS games at how do they make characters with 200+ different weapons.

    I bought this http://3drt.com/3dm/modern-firearms/modern-firearms-animated-shots.htm.
    I thought it i would learn how it is done, however, it wasn't made separatly, the hands and weapons are always together.

    What i thought is i need to make the hands and the weapons separately and position the weapon on the hands with the game engine, using helper bones.
    Am i thinking wrong?

    How should i tell an artist to make it the way it needs to be?

    Thanks for any help.
     
  2. RoXCoder

    RoXCoder

    Joined:
    Mar 3, 2012
    Posts:
    98
    Anybody?
     
  3. Morning

    Morning

    Joined:
    Feb 4, 2012
    Posts:
    1,141
    On hands have a helper "weapon" that will hold the weapon.
    Then in modeling app position the gun in arms, animate it and everything.
    After that export hands with the helper(if not already) and after that export weapon with the same helper.
    Then in unity when you import arms and weapon just snap these two helpers to the same position.
     
  4. RoXCoder

    RoXCoder

    Joined:
    Mar 3, 2012
    Posts:
    98
    When you say "helper", what are you referring to?
     
  5. RoXCoder

    RoXCoder

    Joined:
    Mar 3, 2012
    Posts:
    98
    Oh and, if i do it this way, how can i separate the animation for the hands and for the weapon?
    I don't think unity will know that the weapon used in the animation is the one that im going to snap on the hands.
     
  6. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,508
    From what I understand, basically you set up your character with its animation as usual. In Unity, or your modelling application, you have an 'empty' attached as a child of your character's hand. You might name it "weapon".
    Then, in Unity, you just make your weapon a child of the "weapon" empty. As the player animates, the weapon automatically follows the empty's position and rotation and such. If you player's hand turns, so does the empty and the weapon.
    Now, if you want the weapon to animate, that would just be an animation on the weapon, not the player.

    That way, it doesn't matter what you put into your player's hands. It follows the player's hand movements and such. The weapon is just a child object, stuck to your hand. The player animation controls the player's body...hands, feet, etc, and doesn't -need- to know or care about what is attached to the hands.
    Hopefully this makes sense, and is correct and useful :)
     
    JynJie and ExtremePowers like this.
  7. RoXCoder

    RoXCoder

    Joined:
    Mar 3, 2012
    Posts:
    98
    It helps me alot until that concern.
    How do i make the weapon a child of the hands if the player have the ability to change to another weapon, then what?
     
  8. Morning

    Morning

    Joined:
    Feb 4, 2012
    Posts:
    1,141
    Hide/unhide weapon. Child/Unchild.
     
  9. RoXCoder

    RoXCoder

    Joined:
    Mar 3, 2012
    Posts:
    98
    So far its clear, but i still dont know what type is the "helper".
     
  10. Morning

    Morning

    Joined:
    Feb 4, 2012
    Posts:
    1,141
    Usually it's a bone.
     
  11. Javila

    Javila

    Joined:
    Jul 3, 2012
    Posts:
    8
    - jc_lvngstn
    "As the player animates, the weapon automatically follows the empty's position and rotation and such. If you player's hand turns, so does the empty and the weapon."

    Why even use an extra helper? why not just parent the hand to the gun? instead of Gun>helper>hand why not just have it Gun>hand?

    when animating i just parent the weapon to the hand controls anyways. would this be a problem or do you guys think it will be fine with out using the extra helpers there?
     
  12. proandrius

    proandrius

    Unity Technologies

    Joined:
    Dec 4, 2012
    Posts:
    544
    For my rpg, I also need to switch items on hand, so basically in maya I have a child on that hand which has dummy cube which follows all the rotations and position with the palm when animating and in game I just switch that dummy cube with weapons.
     
  13. Javila

    Javila

    Joined:
    Jul 3, 2012
    Posts:
    8
    by "child" do you mean another bone/joint? or do you just have the dummy cube parented to the hand joint??
     
  14. proandrius

    proandrius

    Unity Technologies

    Joined:
    Dec 4, 2012
    Posts:
    544
    Yes it's just a dummy cube which is parented to the palm joint.
     
  15. wechat_os_Qy06eaOhICF9NcZoMWMLtv5cI

    wechat_os_Qy06eaOhICF9NcZoMWMLtv5cI

    Joined:
    Feb 1, 2018
    Posts:
    33
    What if you have animationes with weapon?How to handle this situation?
     
  16. NewMagic-Studio

    NewMagic-Studio

    Joined:
    Feb 25, 2015
    Posts:
    432