- Home /
Skinned meshes from separate files sharing the same skeleton instance
I'm very new to Unity but am an experienced game developer / animator, and I'm currently struggling to figure out the interface for making a rigged character with swappable clothing and animation sets.
The data structure I want is:
one file contain the rig / skin mesh
separate files for each animation / emote
separate files for each article of clothing
When I upload a rig file that contains all of the animations and all of the clothing, everything works great. You just drag that one prefab into the world (wearing everything at once) and delete the clothing you don't need. That all goes exactly as expected (yay!)
Sourcing animations from separate files also appears to work beautifully, and you can just pull them all into the same Animation Controller and you're off to the races.
The problems I'm running into are specifically with splitting the articles of clothing out into separate files. When I take the same file that works as one big bundle and export off clothing pieces into separate files, I can drag those individual pieces into the world as well. They can play animations and use the same animation controller. BUT I haven't figured out how to get them to share the same specific avatar instance ("Avatar" is Unity for "Skeleton", right?). If you set the clothing object's avatars to "copy from other" and target the body avatar, I would have expected that to work but it definitely does not.
How do you get two skinned objects to share the same skeleton instance?
Is it possible through the UI? From what I've seen so far I'm guessing that you have to do this in script, but I wanted to check before I go down that road.
Any insight anyone could give me on the right data setup for animated things wearing other animated things would be very much appreciated. Thanks!
Answer by whydoidoit · Mar 15, 2014 at 07:57 PM
On the skinned mesh renderer you need to set the root bone of the model, the rest of the bones have to be named the same of course.
You often import the part model with it's own copy of the rig and just delete that.
Thanks for your response!
Huh, I did mess around with that root bone, but it definitely did not behave as I'd expect. So if I drag the body mesh and the clothing mesh into the scene, they both automatically create their own skinned$$anonymous$$esh assets and their own Avatar assets (that have bones by the same names since they refer to the same skeleton in the source file.
When I go to select the root bone on the clothing element, I see two copies named "hips_bone", one from the body and one from the clothing item. If I change that to the other copy, it draws the bounds box around the body mesh rather than the clothing mesh, but it doesn't appear to change the animation at all.
You've used this setup in your own stuff and found that it works for you?
Thanks again for the response!
Further to whydoidoit's answer, try telling each additional Skinned$$anonymous$$eshRenderer to use the same "bones" array using the line:
mesh2.bones = mesh1.bones;
Your answer
Follow this Question
Related Questions
How to create avatar for Non Human Skeleton ? 1 Answer
Using Locomotion with different avatars 1 Answer
Modify humanoid skeleton at runtime and retarget animation 1 Answer
Add more bones to skeleton - vertebraes definition...? 0 Answers
How to animate a model that doesn't have arms or legs (just feet and hands) 1 Answer