- Home /
The question is answered, right answer was accepted
Best pipeline to import multiple weapons into Unity for characters?
Hey Everyone,
I'm building an RPG right now and I'm having some trouble determining the best way to import and attach all these weapons to a character. For instance, I have a knight and let's say this knight will be able to choose from 5 swords. My original thought was to have the swords all in different maya files and import them seperately. Then instantiate the different swords depending on what the player has decided to purchase as a child of the "hand".
My artist tells me there's a problem with this though because of how the character was rigged in maya. If we do it the way I was thinking, we would have to import two separate bone structures and find a way to merge the two onto a single character. The alternative he presented was to actually import every weapon the character MIGHT use all at once in the single maya file and then programatically hide/unhide the meshes as the character changes them. This would allow for a single bone structure and no need to break anything. Which might be fine if you only had 5 weapons. But for an entire game where the player can possibly switch jobs; say you have 10 jobs and a menial 10 weapons per job. That's 100 weapons total at least and you have to load all 100 at once? Even hiding all non-active weapons, that still sounds like a nightmare to manage and a huge unnecessary strain on the computer.
So, my question boils down to this. What would you recommend as the pipeline to import customized weapons into the game so that it's effecient but also doesn't produce a ton of overhead to prep for?
Thank you for your help, -Tim-
"...how the character was rigged...": does each weapon have its own bone, so a cutlass swings much more than a dirk?
I think a typical $$anonymous$$$$anonymous$$O has just animations for swinging a small, medium and huge weapon. Then you can mix&match weapons to characters. Can even bring in weapons not made with that character in $$anonymous$$d.
Yes, I think my animator has rigged the weapon onto the model. So you're saying model the character without the sword then model the sword separately. Animate a generic attack then import them separately into unity. At which point, realign the weapon to the hand as a child so it swings with the original animation?
Answer by Owen-Reynolds · Aug 05, 2013 at 06:01 PM
Restating from the comment:
Typically, you'd have the hand bone double as the generic weapon bone. In Unity, child an empty to the hand bone, placed where the weapon is gripped, and aimed/rotated with +Z along the shaft. To add any model as a weapon, child it to that empty, localPosition and localRotation 000 (or child to the hand, copying the empty's localPosition/rotation.)
The weapons might need to be childed to their own "positioning" empties. That would allow you to set the weapon 000 exactly where it should be gripped. So positioning the weapon in the hand is a "match tab A with tab B" thing.
The tricks works if you don't have a hand bone. Just child the "weaponGoesHere" empty to the forearm (and still where the hand is.)
Answer by KazeEnji · Aug 05, 2013 at 07:27 PM
Gotchya. Yeah, I've used a positioning setup similar to that in the past. So as long as the weapon is a child of the empty gameobject on the hand in Unity, it should be aligned and move just like the animation has it.
Thanks, -Tim-