Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by korotkevich.md · Jun 09, 2011 at 01:38 PM · clothskinned mesh

Problem with clothing on character

In my application user can wear different clothes. Clothes for character are skinned meshes with bones, identical to character's bones. Clothes should dress on a character through attaching clothes bones to character's bones. The problem is that bones are attached, but clothes mesh worn “unevenly”, some parts of character's body get off from clothes (see pic.1). Dressing should be processed at run-time, clothes are load from asset bundles. Please, see my code.

Start Download() function: function StartDownload () { if (url.IndexOf ("file://") == 0 || url.IndexOf ("http://") == 0) { download = new WWW (url); } yield download; assetBundle = download.assetBundle;

 if (assetBundle != null)
 {
     loadedObject = assetBundle.mainAsset;
         
     if (loadedObject != null) 
     {
     instanced = Instantiate(loadedObject);
     // get all components of instanced object
     numT = instanced.GetComponentsInChildren(Transform);
     // get mesh from array of components
     objectMesh = getMesh(numT);
     // get link on SkinnedMeshRenderer
     skm = objectMesh.GetComponent("SkinnedMeshRenderer") as SkinnedMeshRenderer;
     // get link on sharedMesh from SkinnedMeshRenderer
     m = skm.sharedMesh;
     // add mesh filter
     objectMeshFilter = GameObject.Find(objectMesh.name).AddComponent(MeshFilter);
     // add current clothes mesh to mesh filter
     objectMeshFilter.mesh = m;
     // wear current clothes on girl
     wearing();
     // destroy instanced object
     Destroy(instanced);
     }
     else
         Debug.Log("Couldnt load resource");    
         }
 else
 {
     Debug.Log("Couldnt load resource");    
 }}

Wearing() function:


function wearing() {
        bonesArr = new Transform [numT.length-1];
        // we start at [1] because transform of game object itself is at [0] position
        for (i=1;i
  
    it is a mesh
        if (bonesArr[b].renderer != null) {
        // bind mesh to root bone 
        bonesArr[b].transform.parent = girl.Find("root").transform;
        bonesArr[b].transform.position = girl.Find("root").transform.position;
        }
        // change names of attched clothes bones 
        if (bonesArr[b].renderer == null) {
        // gameObject doesnt contain mesh -> it is a bone
        bonesArr[b].name = bonesArr[b].name + objectMesh.name;
        }
        }
}

  
It happened that all clothing was modeled around this character, staying in a T-pose. Now, I try to dress this clothing on a character staying in another, “default” pose. Maybe, problem in it? But, as I understand, if mesh rigged to bones and bones changed their positions, mesh should follow bones. So, please review my code and tell me, how can I solve this problem? Perhaps, I don't understand something in mesh behaviour in Unity.

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by kablammyman · Jul 27, 2011 at 06:47 PM

while I'm having the same problem as you are, I dont have a definite answer...but there are somethings that could help you out.

1) I dont see where you are setting the bones you setting to the skinned mesh renderer

2) I dont see where you are setting the bind pose or weights for your bones.

3) if you have a skinned mesh renderer (and you do since you are trying to animate the model) you dont need the normal meshFilter... in fact, once you have a skinned mesh renderer, Unity ignores the mesh filter attached to the object.

Let me know if you solve this problem, since I need help with this too.

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 nasoukikos · Jan 20, 2013 at 02:52 AM

you could use interactive cloth and have a box collider on the bones of the shoulders or the waist. then adding a mesh collider to the body, the cloth would smoothly cover it. but this way need more processing power

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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How is Cloth performance related to the whole vertex count of a skinned mesh with cloth component? 0 Answers

Clothing and weapon animation 1 Answer

Cloth Trampoline and 3rd Person Character 2 Answers

Skinned Cloth 1 Answer

how to find existing cloth position? 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