Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by Disrar · Jul 16, 2015 at 08:14 AM · animationbonesskeleton

Assigning a clothing object to a character's skeleton?

I am trying to do an equipment system where there are interchangeable clothing items that get instantiated onto the player as they are equipped, as is standard in most RPGs. So far I've got the position of the clothing after they're instantiated fine, but I can't figure out how to get the clothing to animate.

I've read that I should set the root bone of my clothing object's skinned mesh renderer to the root bone of my character. However, that seems to only allow the transforms of the root bone that I assign (the "hips" bone in this case) to actually affect the mesh. Sometimes it even causes weird offsets in the position of the mesh as well. I'm hoping I'm just misunderstanding something here, because I can't understand why it wouldn't work. Both the character and the clothing mesh were made with the same skeleton.

Am I going about this in the wrong way? There are only two other options I can think of. Copying all of the character skeleton's transforms to a skeleton that is on the clothing object (or parenting the clothing's bones to the character's), but that seems fairly complicated and inefficient. The second one being to play the same animation on each clothing object. That would mean having multiple skeletons animating at the same time, and wouldn't that cause a bit of a performance hit?

Been frustrating the past few days trying to figure this out with everything else in my game going relatively smoothly, and maybe I'm just overthinking it. Just thought I'd ask here for advice before I bite the bullet and just go with option #2 that I listed.

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image LaJolly · Aug 05, 2015 at 01:49 AM 1
Share

Bumping this question! I would also like to know the answer.

avatar image getyour411 · Aug 05, 2015 at 02:34 AM 0
Share

I'm not sure parenting clothing to a single bone (i.e hip) makes sense, as mesh vertices are often influenced by more than one bone so in that scenario I would expect oddities depending on the pose or animation; link to that?

avatar image LaJolly · Aug 05, 2015 at 02:48 AM 0
Share

http://docs.unity3d.com/$$anonymous$$anual/class-Cloth.html

When you add that script to the mesh you want animated, a Skinned $$anonymous$$esh Render will also appear,

http://docs.unity3d.com/$$anonymous$$anual/class-Skinned$$anonymous$$eshRenderer.html

You'll see there is a Property for Root Bone. When both OP and I apply the root bone of the hips, it causes the clothing to appear in an unnatural location in contrast to where the hip bone is actually located. (OP, are you using the $$anonymous$$ixamo rig by chance?)

avatar image Disrar · Aug 05, 2015 at 03:19 AM 0
Share

I am using Rigify in Blender for my skeleton. I have a temporary (hopefully) workaround by manually adding bones to variables.

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Cherno · Apr 05, 2016 at 06:36 PM

This UA thread explains how to map the bone array from the clothing mesh to the cahracter mesh:

Shared skeleton and animation state

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Disrar · Apr 06, 2016 at 11:06 PM 0
Share

Thanks for that link. I can't believe I didn't find it when searching for this a while ago. However, that doesn't seem to work for me, as the mesh just seems to disappear afterwards.

A comment in there suggested something so simple, I feel like an idiot for spending so much time trying to figure it out. After trying it... it works (although it seems to shrink the mesh of the clothing for some reason...)!

That answer was simply

 object.GetComponent<Skinned$$anonymous$$eshRenderer> ().bones = target.GetComponent<Skinned$$anonymous$$eshRenderer> ().bones;
 
avatar image
1

Answer by Disrar · Aug 05, 2015 at 03:32 AM

I've created a temporary workaround for parenting a clothing's skeleton to the character's, however it isn't ideal as I haven't figured out a way to find bones automatically.

I set up a script that contains Transform variables for each bone on the character,

         using UnityEngine;
         using System.Collections;
         
             public class CharacterBoneList : MonoBehaviour {
             
                 public Transform Hips;
                 public Transform Spine;
                 public Transform Chest;
         .
         .
         . etc for each bone
 }
 
 

then call ParentClothBoneToChar () from a script attached to the clothing item that has variables for each bone as well:

         using UnityEngine;
         using System.Collections;
         
     public class ParentClothBoneToChar : MonoBehaviour {
     
         public Transform clothHips;
         public Transform clothSpine;
         public Transform clothChest;
         ...etc
 
         
             public CharacterBoneList charBones;
                     public void ParentBonesToChar () {                charBones=GameObject.Find("Player").GetComponent<CharacterBoneList>();
                     
                             clothHips.SetParent (charBones.Hips);
                             clothSpine.SetParent (charBones.Spine);
                             clothChest.SetParent (charBones.Chest);  
                     .
                     .
                     . etc, for each bone.
 }
 }

Of course this means having 4+ skeletons on each character since you need one for each article of clothing. I know that bones in Unity are simply GameObjects, but having over 4x than what is needed seems a bit inefficient to me.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by LaJolly · Aug 05, 2015 at 06:21 AM

I found the answer! The clothing mesh needs to be skinned to the rig and imported along with the fbx.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Disrar · Aug 05, 2015 at 07:25 AM 0
Share

Do you mean importing the clothing mesh, with the skinned rig attached, then deleting it and assigning the root bone to the one that your character is attached to?

Or do you mean keeping their own skeletons, then animating them at the same time as each other? That might be better than my current solution, but you still end up with multiple rigs being needed per character.

avatar image LaJolly · Aug 05, 2015 at 07:32 AM 1
Share

It's probably unnecssary to import the whole rig with the weight mapped mesh, but as long as your mesh contains the weight map information, it should work.

You need to actually skin your mesh clothing to the rig in a program like maya or blender. You need to have it "skinned" to use the "Skinned mesh render" properly. Skinned = Weight $$anonymous$$apping to the rig. The Unity Clothe physics seems to require at least some info in weight mapping to work right.

I just put the clothing on the character in $$anonymous$$aya, Smooth Binded the mesh to the proper joints, smoothed some of the weight mapping for more natural movement in the top of the dress, and exported it and the rest of my meshes and rig as a avatar.fbx. I then imported it into Unity and added the Physics competent script to the mesh that is intended to make use of the physics. You then need to edit the colliders and cloth constraints for polish.

avatar image Disrar · Aug 05, 2015 at 07:58 AM 0
Share

Oh, so the character mesh and clothing mesh are in the same file? That does work for making the character and clothing item work with the same rig. However, the filesize of that file would become very large with dozens of clothing items added in. It may not be a problem since I create prefabs for the items anyways, and could separate them out.

All my meshes are skinned, I'm just importing them separately, each with their own rig. They work fine on their own, but when I try to parent, say, shirt to the character's rig, the only thing that seems to affect the mesh is the position of the root bone and not the arm bones. If I go through the process of parenting each individual bone from the shirt's rig to the character's rig, it will work. However, that's tedious and time-consu$$anonymous$$g. This is why I felt there was a better way, or at least a more automated way built into Unity to do the parenting.

Thanks for your help, you're giving me some ideas to try out. Just hope they work.

avatar image Yiorgos Disrar · Apr 05, 2016 at 08:01 AM 0
Share

Well, did they work after all? I'm trying to do the same thing -and I'm a developer, not 3D modeler, so it's giving me a huge headache... A set of instructions would be ideal, if possible :)

avatar image Disrar Yiorgos · Apr 06, 2016 at 11:08 PM 0
Share

None of the ones I came up with worked out, so I kind of tossed this to the side until now, even rewriting all of my inventory and item/equipment code. The solution I found was so simple though. See my comment under Cherno's answer. You may even be able to get the solution from Cherno's link to work for yourself as well.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Animating bones and the entire skeleton together 0 Answers

Can I restore bone locations in skeletal animation after the character was deleted? 0 Answers

How to separate bones from a 3dsMax skeleton? 0 Answers

creating a disolvable ik rig in blender for unity3D mecanim 0 Answers

scaling bone animation of salamander tongue looks fine in max but breaks in unity 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges