Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Cloth not responding to parts of ClothSphereColliderPair.

Discussion in 'Physics' started by YoungXi, Jun 20, 2017.

  1. YoungXi


    Jun 5, 2013
    Just look at the picture:

    The colliders are dynamically generated once based on the bone transforms. And are subdevided using a BVH method. But, when I set up the ClothSphereColliderPair[], the right legs colliders always fails.

    Here is the code how I setup and pass the ClothSphereColliderPair[] to the Cloth component:
    First, I already have SphereColliders[] colliders generated;

    private void CreateColliderPairs()
    List<ClothSphereColliderPair> pair = new List<ClothSphereColliderPair>();

    for (int i = 0; i < refBonesCount; i++)
    if (skinnedBVHs != null)
    int parentId =;
    BVHNode<AABB>.Traverse(skinnedBVHs.bvh, (BVHNode<AABB> node) =>
    if ( != parentId)
    if (parentId == thighRIndex)
    Debug.Log("skinnedBVH is thighR");
    pair.Add(new ClothSphereColliderPair(colliders[], colliders[parentId]));

    // If I only add the right legs' colliders in the hard coded way, it would work.
    //pair.Add(new ClothSphereColliderPair(colliders[skinnedBVHs[pelvisIndex]], colliders[skinnedBVHs[thighRIndex]]));
    //pair.Add(new ClothSphereColliderPair(colliders[skinnedBVHs[pelvisIndex]], colliders[skinnedBVHs[thighLIndex]]));
    //pair.Add(new ClothSphereColliderPair(colliders[skinnedBVHs[thighLIndex]], colliders[skinnedBVHs[calfLIndex]]));
    //pair.Add(new ClothSphereColliderPair(colliders[skinnedBVHs[thighRIndex]], colliders[skinnedBVHs[calfRIndex]]));

    colliderPairs = new ClothSphereColliderPair[pair.Count];

    As you can see, the ClothSphereColliderPair is created into a List<>, and then copied to the colliderPairs, which is an array.

    And for the case to setup the collider pair to the cloth, simply do Cloth.sphereColliders = colliderPairs;

    I thought the Cloth component has a limit of 30 for the sphere collider pairs. Anyway my colliderPairs is definitely less than that.
  2. nbaris


    Jan 13, 2015
    Were you able to figure this out? I have the same issue
  3. Cover-Club-Media


    Apr 30, 2015
    I found this happens when you overlap colliders like I see in your picture. I prefer capsules and I line up the ends like joints. I also add a bit more on my colliders to help and I try not to scale the transform as I thought it was doing odd things to the cloth.

    Last thing, I made a robe like that in your picture. It looks like you have a full front. I found it to be a huge pain(with world settings) and the result on my end was subpar compared to a robe with bathrobe type design. I redid all my characters with several styles of that kind of robe. Unity cloth is really great but it doesn't work well with some designs.

    Hopefully that helps you.
    nbaris likes this.