Cloth don't interact with prefabs GameObjects

Hello guys,

i just start to create a basketball shoot game.

So i use cloth component for the net. After setting up it works fine. The problem is that the cloth don’t interact with the balls (GameObject Prefabs).

But when i create a sphere in the scene (with rigidbody and sphere collider, like GameObject prefab), the cloth interact with the sphere.

How can i make the cloth interact with prefab GameObject?

Thanks! :slight_smile:

Regards, Sam.

in the collision detection (rigidbody panel), i select continious dynamic, but nothing change…

It works only with the balls present in the scene. How can it works with a prefab object?

There are two types of cloth in Unity, the Cloth (fast) component and the Interactive Cloth (slow) component. On the Cloth component you have to attach your collider to the Cloth, to define that the collider can interact with the Cloth. The Cloth inspector window has an array for the possible colliding collider.
The interactive cloth is more expensive (cloth simulation), it collides without attaching the colliders on it.

how can i use the interactive cloth?

because i want my cloth (basketball net) to collide with prefabs object (it’s not on the scene so i can’t attach my collider prefab).

can i use the script from unity 4 that used for “interactive cloth” and copy paste it in my unity version?

any help?

Hi i just solved this.

First you declare an array of capsule colliders
public CapsuleCollider[ ] colliders;

then you call this code in any function when instantiating the prefab

///////
Cloth b = Object.GetComponentInChildren (); //get the cloth from the gameobject
colliders = new CapsuleCollider[4]; // can be any size you like

//set the colliders from the gameobjects in the scene

colliders[0] = GameObject.Find (“QuickRigCharacter_LeftUpLeg”).GetComponent();
colliders[1] = GameObject.Find (“QuickRigCharacter_RightUpLeg”).GetComponent();
colliders[2] = GameObject.Find (“QuickRigCharacter_LeftLeg”).GetComponent();
colliders[3] = GameObject.Find (“QuickRigCharacter_RightLeg”).GetComponent();

//set the collider array of the cloth to the array you just created
b.capsuleColliders = colliders;