- Home /
How do I "equip" this weapon properly to a model? (IMG)
I have a custom model, and a custom weapon. The designer doesn't know the answer, so I'm asking the world, how do I "equip" this weapon to the model?
In my head I think it should be a simple process of attaching the weapon model to the hand of the character model, but that doesn't work unless I adjust the rotation etc.
What's the common way of setting all this up, making it re-usable in other models etc? ( like other player or enemies)
Thanks!
Answer by jmatthews · Oct 10, 2013 at 03:12 AM
You just attach the object to whatever bone most closely matches the attachment point. If need be you add a bone in the hierarchy to get the proper placement.
Generally the matrix transform tree handles the rest. Per your example, a mace attached to the wrist bone will move when any bone higher in the tree moves. Attach it to a "weapon" bone you make for this purpose and you can do some additional work to it, such as making it sway around a bit instead of appearing to be glued to the hand.
To make it portable to other weapons and characters you need to design a "weapon socket" concept where each model will have a similarly named bone and programmatically attach the weapons at run time.
Cool -- is adding a bone (in unity) the same as adding an empty game object attached to a bone that's already there?
And what's the best method of ensuring that the weapon, when instantiated during the game, ends up being "held" at the right point?
You'll want to add the "weapon bone" or "socket" when you author the model, and then mecanim will find it when it builds your in-game rig. Just dig into the hierarchy after you import it and you'll see it there.
For weapon placement you'll also want to author the weapon rig with a bone in the right pivot point. For example, a sword may have a bone thats a bit below the hilt and you're going to connect the hilt bone to the weapon socket on your model.
$$anonymous$$ore difficult weapons may require more intricate rigs, both on your weapon and on your model, for example a spear may require each hand to connect to it, or a bow would need at least one bone for the handle and one for the string.
You'll have to trial and error this a bit until you get a look that you're satisfied with.
Your answer
Follow this Question
Related Questions
Issues with accessing properties in c# 1 Answer
Character Equip Animation 0 Answers
How to deal with different Weapon animations on Equip? 1 Answer