Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

What's the general approach to support variety of weapons in player's hands?

I currently have a 3d model that has empty hands. Should I have separate weapon models that I will just create and render into players hands in the game, or should I implement them in the actual model instead?

If they are not in the model, then how do I make the weapon appear in the right position, especially when considering that I want the player to have a walking animation and perhaps running too.

share|improve this question
1  
If you have a 3D model with animations you probably have a bone animation system. If so, use the "hand" bone position and orientation to render the weapon :) –  Grimshaw Feb 5 '12 at 21:14
    
@DevilWithin can you point me to some articles that discuss these matters? –  rFactor Feb 5 '12 at 21:34
    
possible duplicate of How do you add equipment to a 3D character model using XNA/Blender? –  bummzack Feb 5 '12 at 22:11

2 Answers 2

You want to get the position and general orientation of the hand, then put the weapon in it. This saves you from having to have duplicate character models for each weapon.

You then might want to consider setting the other hand after this has happened to be positioned on a forward grip, or on the barrel of a shotgun, or just by your side for a pistol etc.

share|improve this answer

In general, the way this works is very simple. Your characters have a list of bones, which are animated by the animation system. You renderer takes these animated bones and uses them to draw the mesh via skinning or some similar technique.

So you simply add an extra bone to the animation system. This bone is not weighted to any vertices; it's there solely to position objects your character carries. Typically, this bone is either a child of the animation root or a child of the hand.

When you execute your animation system and get the bone-to-object space matrices for each bone, you get one for the "extra" bone as well. Just use that as the transform for the object you want the character to "carry". If the animators and modelers did their jobs (animation must position and orient the bone correctly, modelers must build the mesh to fit the hands and center the object on the place where the character will hold it), then the object will appear in the character's hand.

share|improve this answer
    
I was just wondering how good this technique will work, if the objects that are carried can vary substantially in size. Etc, a broadsword vs a longsword. The difference in weight might give some unconvincing animations.[?] –  Cardin Feb 6 '12 at 1:02
1  
@Cardin: And? If you decide you need separate "longsword idle" and "broadsword idle" animations, that's up to you. It won't affect how you put the weapons in the hand of the characters. You asked how to attach weapons to characters, and that's how you do it. How you make it look convincing is up to you ;) –  Nicol Bolas Feb 6 '12 at 1:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.