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

How can I put a weapon in my character's hands?

Discussion in 'Editor & General Support' started by NoobFPSDude, Jun 20, 2013.

Thread Status:
Not open for further replies.
  1. NoobFPSDude

    NoobFPSDude

    Joined:
    Feb 25, 2013
    Posts:
    62
    Hey, guys. I just cannot seem to find any tutorial or step-by-step thing on how to do this. I have a 3rd person character model and I want to put a sword in his hand and see it animate while previewing Mixamo animations and such, to make sure it's positioned correctly and such. My problem is I do not know how to do this. I know it has something to do with parenting the weapon to the arm/hand or something along those lines, but could someone give me a tip or a video showcasing what I want to do? Thank you!
     
  2. NoobFPSDude

    NoobFPSDude

    Joined:
    Feb 25, 2013
    Posts:
    62
    Friendly Bump. I'd really like to know how to do this. *If it's any more important information, the weapon is going to be permanently attached to the hand. I don't want a sheathe or a 'switch weapons' function or anything like that. I just want a weapon to stick to my player model's hand.
     
  3. Batigol

    Batigol

    Joined:
    Oct 17, 2012
    Posts:
    234
    You can link you weapon to the hand bone
    weapon.transform.parent = [hand bone object].transform
    weapon.transform.localPosition = Vector3.zero

    Then adjust the eulerangle to match hand mesh
     
  4. NoobFPSDude

    NoobFPSDude

    Joined:
    Feb 25, 2013
    Posts:
    62
    I tried doing this and for whatever reason it didn't work. I tried making it a script, but no matter what I did it gave me an error. :mad: LOL. This should be SO simple, but seriously! It takes me 2+ days to stick a damn sword in my characters hands??? Oh, well... I guess Unity game-making isn't as easy as people claim. Any other ideas? I tried putting a combinechildren script on my hand, but that didn't work either, assuming it even could've.
     
  5. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I don't know who's claiming it's easy. It's a programming language and editor, it's not a "game maker". Combine Children is nothing to do with this. All gameobjects have something called a transform, and this transform can be made to be a parent or a child. You simply drag the sword as a child of the hand and it will work.

    To do this process in code you use weaponObject.transform.parent = hand.transform; Assuming you change the names, this will cause the sword to be a child of the hand. You should look this stuff up and get a clearer idea. The above poster is saying the same thing as I am.
     
    eaque likes this.
  6. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,122
    Do as hippocoder says, or just add an empty gameobject and attach it as a child of the hand and rotate the transform as you need it, then in code attach the weapon to the empty gameobject. This will allow you to move the weapon exactly how you want it and change the weapon easily in code.
     
  7. Batigol

    Batigol

    Joined:
    Oct 17, 2012
    Posts:
    234
    show your code, some one may easy to help you.
    link the weapon to hand point is the easiest way to do
     
  8. NoobFPSDude

    NoobFPSDude

    Joined:
    Feb 25, 2013
    Posts:
    62
    OK, I actually figured out why I couldn't see it. I just needed to get an animation clip playing, because, for whatever reason, the Mixamo Asset Store doesn't want me testing it out with the weapon in hand. However, moving the sword in the hierarchy worked like a charm! Now, I only have one small problem. It's not huge as the game is FAR from complete and I'm literally just diving into the first percent. But, I moved my character closer into the terrain so I could see what it looked like on the ground instead of the air. But, when I go back into game view to see him animate, he teleports back to his original spot in the air (0,0,0). He goes back on the ground, though, when I step back into scene view. Does this happen for anyone else?
     
  9. netherboss123

    netherboss123

    Joined:
    Jun 29, 2014
    Posts:
    106
    Lol all u had to do was move the model where u wanted it and moved it into the player model in the hierarchy.
     
  10. alfaro190

    alfaro190

    Joined:
    Jun 2, 2014
    Posts:
    6
    even with transform you may find that it doesnt work. What you really need is an animation that is similar to the pose you want then using unity IK modify a transform to position and lock the hands to where you want them. So when you transition between animations the hands are always in the right spot. When you need to stop the hands being locked simply set the IK weight to 0.

    Make sure you set in mechanim IK pass set to true.
     
  11. Honour-Demon

    Honour-Demon

    Joined:
    Aug 19, 2013
    Posts:
    9
    I'm a Necromancer. Deel with it :)

    Edit: Miss Read the Q

    Find the hand bone in rig. Child Weapon to hand bone. Done

    No,..Seriously, Deel with my Necro Powers *.*
     
    Last edited: Mar 21, 2017
    saiso likes this.
  12. executer

    executer

    Joined:
    Mar 29, 2017
    Posts:
    7
    there is no child object for hand in my 3d model.i downloaded 3d character from mixamo.i want to create animation for a person picking a object on table.i got similar animation on mixamo but how can i attach object with animation there is no child object for hand in my 3d model.any help on this will be highly appreciated
     
  13. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I could but I won't, so there! Oh alright then :(
     
Thread Status:
Not open for further replies.