Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Clothes dont follow rigg

Discussion in 'Scripting' started by Code4Pro, Jun 20, 2019.

  1. Code4Pro

    Code4Pro

    Joined:
    Oct 30, 2018
    Posts:
    4
    Sorry for my bad english, i m french.
    i have a problem with clothes . ( i m on Unity 2018.3.6f1)

    I have buy an avatar.
    I created clothes for this avatar.
    everything is set in humanoid rig.
    If I import the avatar change with the clothes, it works well.
    If i import the clothes alone, it's dont follow the bones avatar and remains in Tpose.

    I had this problem with the avatar of Daz / Genesis. a script allowed to correct this but this script does not work on this new avatar. could someone please help me?

    Sure, i can pay for help to fix that .
    thank you.

    The Daz Script
    Code (CSharp):
    Code (CSharp):
    1.     using System.Collections;
    2.     using System.Collections.Generic;
    3.     using UnityEngine;
    4.     using System.Linq;
    5.  
    6.     public class Copy_Bones : MonoBehaviour {
    7.  
    8.         public GameObject SourceObject;
    9.  
    10.         // Use this for initialization
    11.  
    12.         void Start () {
    13.             Copy();
    14.         }
    15.  
    16.  
    17.         void Copy()
    18.         {
    19.             if (SourceObject == null) return;
    20.  
    21.             var sourceRenderer = SourceObject.GetComponent<SkinnedMeshRenderer>();
    22.             var targetRenderer = GetComponent<SkinnedMeshRenderer> ();
    23.  
    24.             if (sourceRenderer == null) return;
    25.             if (targetRenderer == null) return;
    26.  
    27.             targetRenderer.bones =
    28.                 sourceRenderer.bones.Where(b => targetRenderer.bones.Any (t => t.name == b.name)).ToArray ();
    29.         }
    30.     }
    31.  
     
  2. Laperen

    Laperen

    Joined:
    Feb 1, 2016
    Posts:
    1,065
    Hard to tell without looking at the models(not that I want to), but sounds like a mismatch with the bones between models. If you extracted the clothes without the bones, then that is a problem aswell since you most likely need all relevant bones and bone names to match between models in order for your script to work.

    Make sure these are true first and see if it works:
    - The base model and clothes must have the same bone names and hierarchical structure
    - Whatever bones your clothes were skinned to from the original model need to be extracted with it aswell.
     
  3. Code4Pro

    Code4Pro

    Joined:
    Oct 30, 2018
    Posts:
    4
    Thank you for your answer.
    Bones have the same name.
    I have been using this script for a long time for the avatars of Daz / Genesis.
    There is this problem on it too. but this script works very well on it.
    I do not know why it does not work on my new mesh, and I need another solution.
    A similar script or something that could help me fix that.
     
  4. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    Do targetRenderer.bones and sourceRenderer.bones contains any bones at all? You may add Debug.Log to check this.
     
  5. Code4Pro

    Code4Pro

    Joined:
    Oct 30, 2018
    Posts:
    4
    Yes :/
    The debug Log have no error ...
    if i apply on root the mesh stay in T pose .
    if i apply on TopBody part n the mesh disappears.
    I dont understaind :/