Unity Community


Results 1 to 13 of 13

  1. Posts
    87

    Attaching gun to hands?

    Hi (again)!

    I have a somewhat basic question I guess, but how can I make a gun stick to the hands of my character?
    Is this setup in the 3Dapp (Im using Cheetah3D) or in Unity?

    I'm trying to get the arm of the char to hold the weapon and then when I move the weapon the arms should "just follow" if you know what I mean...

    But right now I can't even attach the gun, does someone have any input on how to do this?

    // Big bad newbie


  2. Location
    Capitol City New Zealand
    Posts
    3,191
    Hi
    The fps tutorial ones are positioned in the scene and then parented to the camera...

    Drag gun onto camera in hieracy

    Does that help?
    Cheers
    AC


  3. Location
    Ontario, Canada
    Posts
    1,661
    I have never done it in Unity, but basically what you want to do is parent the transform of the gun to the hand bone in your character's skeleton. Simply positioning them and parenting should work, but it may take a bit of tweaking to get it to look right.

    -Jeremy
    GUI-eXtended 1.x is now Open-Source!
    https://bitbucket.org/JeremyHollings...ded_opensource


  4. Posts
    87
    Thanks, my gun is positioned like it should now

    But 2 questions:

    1. How can i make the character hold the gun with both hands? I can only get him to have it as as child to one of them...

    2. How can I make the arms follow the gun and not the other way around (as it is now...)

    Thanks in advance


  5. Location
    Greece
    Posts
    82
    You can put another gun to the other hand. it will be sooo cool!!! :P


  6. Location
    Tuscon, Arizona, United States
    Posts
    213
    And then make them pistols! :P


  7. Location
    Ontario, Canada
    Posts
    1,661
    To get the other hand on might be tricky actually. You might actually need IK code to do that, which isn't the easiest thing to do, but it's not too bad.

    Perhaps someone has a better idea than IK?

    -Jeremy
    GUI-eXtended 1.x is now Open-Source!
    https://bitbucket.org/JeremyHollings...ded_opensource


  8. Location
    Palma de Mallorca - Spain
    Posts
    566
    Make an animation of the character with the two hands together, using IK in your animation app. Then parent the gun to one of the hands, inside Unity. That would be the usual aproach AFAIK.


  9. Location
    Ontario, Canada
    Posts
    1,661
    Quote Originally Posted by GusM
    Make an animation of the character with the two hands together, using IK in your animation app. Then parent the gun to one of the hands, inside Unity. That would be the usual aproach AFAIK.
    That of course would work if he can break it down to a few animations, but I got the impression that he wanted non-canned movement.

    Doleman: If you can fake it with animations, I also recommend that you do so.

    -Jeremy
    GUI-eXtended 1.x is now Open-Source!
    https://bitbucket.org/JeremyHollings...ded_opensource


  10. Posts
    87
    Ok, I've made a very ugly image on what I'm trying to achieve here
    I'm the programmer, not the artist

    The cross on the picture is supposed to be the mousepointer, and the gun is aiming at the cross all the time.
    The hands are just supposed to "hang on" to the gun when it changes direction...




    Does this help? :P


  11. Location
    32.71° N, 117.15° W
    Posts
    5,419
    You might be able to achieve this with physics joints at the shoulder and elbow of the character and then move/rotate the forearm/hand/gun to align with the shooting angle. The result may not be very natural looking.

    Naw, second thought, that probably wouldn't work.

    Another idea might be to create an animation that goes from "gun aimed high" to "gun aimed low" and play the animation to a particular frame based on the angle to the target.

    Not exactly sure how these would be done, but should be possible...


  12. Location
    Palma de Mallorca - Spain
    Posts
    566
    Yes, this is usually built with IK (inverse kinematic) inside the modelling-animating app. of your choice. Cheetah has good IK. Look for the videotuto of the rigged arm and you will understand it better. With this tool you can use a separate bone as the "driver" for the arms chains, just like in your example.

    I would build (in cheetah) an animation with the vertical movement between two extreme poses (looking up and looking down) and then another animation with the horizontal movement.

    Then, in Unity, you will need to build a script interpolating those two animations to be used with the horizontal and vertical input axes. And, of course, attach the gun to the same bone used as an IK target in your animations. But I cannot help you in this, as I am only an artist, not a coder


  13. Location
    New Hampshire
    Posts
    1,352
    Quote Originally Posted by bigkahuna
    You might be able to achieve this with physics joints at the shoulder and elbow of the character and then move/rotate the forearm/hand/gun to align with the shooting angle. The result may not be very natural looking.
    i have a project with a similar control idea on the back burner atm & that was kinda my thought as well. for an FPS view anyway i imagine you can have two arms that are separate jointed objects parented to a master object (for character movement & rotation). the gun arm & gun does the lookat & is clamped to a max angle - the hand on the other is jointed to the gun. never got around to trying it though - but wouldn't that work?
    -O

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •