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 Lesnikus5 · Jun 24, 2016 at 05:00 AM · c#customizationskinskinningclothes

Bug with adding clothes to character's body (twist mesh)

For characters customization I using the simple script:

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 
 public class ClothesSimpleScript : MonoBehaviour {
        
         public GameObject m_attached;
 
 
         void Start () {    
                 SkinnedMeshRenderer targetRenderer = m_attached.GetComponent<SkinnedMeshRenderer>();
                 Dictionary<string, Transform> boneMap = new Dictionary<string, Transform>();
                 foreach( Transform bone in targetRenderer.bones )
                 {
                         boneMap[bone.name] = bone;
                 }
 
                 SkinnedMeshRenderer thisRenderer = GetComponent<SkinnedMeshRenderer>();
                 Transform[] boneArray = thisRenderer.bones;
                 for(int idx = 0; idx < boneArray.Length; ++idx )
                 {
                         string boneName = boneArray[idx].name;
                         if( false == boneMap.TryGetValue(boneName, out boneArray[idx]) )
                         {
                                 Debug.LogError("failed to get bone: " + boneName);
                                 Debug.Break();
                         }
                 }
                 thisRenderer.bones = boneArray; //take effect
         }
 }

Nothing is satisfactory until I came to the import into the project of the clothing that belongs to the legs, ie trousers, pants and so on. They adding to the body of the character buggy. Right leg terribly twisted. Everything else works. Jackets, shirts, etc. also work without problems.

Here pants, standing by themselves (not added to the body of the character):

alt text

But the pants in the game, has added to body using script (disabled visibility of the character body, to better see the pants). As you can see, right leg twisted:

alt text

What's the matter?! I verifies the correctness of the names of all the bones, thought, where can the letter accidentally added a letter - in pants and torso completely identical skeletons! At the same time a female character that's all right, bug happening only with men's clothes (weird, huh?). Pick up the script buggy Men's pants and drop this on a woman's body (skeletons of the all characters is identical) - the same problem! Pants twists on female and the male bodys equally. If I do not use a script, and add pants on scene, add them animator controller, they will normally run, jump, without bugs. It is necessary to apply script - again there is a bug (with any feet-clothing: pants, shorts, etc) ... What do you think?

P.S. Link to my project- https://yadi.sk/d/FhZ0SXNBsjjHM

2.jpg (22.7 kB)
1.jpg (25.3 kB)
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Endless_Aftermath · Jun 24, 2016 at 08:47 AM

A lot of warping bugs happen when you add things after the initial load in. It might be better to have them already attached and then enable them during the script. I had some models that I instantiated weapons into their hands via code. The same thing happened to me. The weapons were warped when the armature would move. When adding a gameObject as a child to any other gameObject, you have to make sure that the parent's transform is zeroed out, other wise the warping will occur because you're applying it to a gameObject whose transform is already transformed, therefore the child takes on that same behavior in a very ugly way. Again, add them in the editor and activate/deactivate through script. It'll save you some time.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Skinning a mesh by Code... 1 Answer

How to change prefab material C#? 1 Answer

how to save a prefab of a object during play mode 2 Answers


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