Instantiated object not interacting with cloth,Instantiated model wont interact with cloth,Instantiated prefab colliding with cloth
Hello. How can I get a spawned monster to interact with cloth? I have adapted the below script from another answer but there is still no interaction.
public class ClothMonster : MonoBehaviour { public GameObject SphereGoon;
void Start()
{
}
void Update()
{
Cloth a = GetComponent<Cloth>();
var colliders = new ClothSphereColliderPair[1];
colliders[1] = new ClothSphereColliderPair(SphereGoon.GetComponent<SphereCollider>());
a.sphereColliders = colliders;
}
}
The script is attached to each cloth mesh, and the monster (which has a sphere collider component), is linked to "SphereGoon."
Any help would be appreciated!,Hi, I am trying to get a spawned monster to interact with cloth in my game world. I have adapted a script from another forum answer, but the instantiated prefab still wont collide with the cloth.
The below code is attached to each cloth mesh:
public class ClothMonster : MonoBehaviour { public GameObject SphereGoon;
void Start()
{
}
void Update()
{
Cloth a = GetComponent<Cloth>();
var colliders = new ClothSphereColliderPair[1];
colliders[1] = new ClothSphereColliderPair(SphereGoon.GetComponent<SphereCollider>());
a.sphereColliders = colliders;
}
}
The "monster" has a spherecollider attached to it.,Hi, I am trying to get a spawned monster to interact with cloth in my game world. I have adapted a script from another forum answer, but the instantiated prefab still wont collide with the cloth.
The below code is attached to each cloth mesh:
public class ClothMonster : MonoBehaviour { public GameObject SphereGoon; // Start is called before the first frame update void Start() {
}
// Update is called once per frame
void Update()
{
Cloth a = GetComponent<Cloth>();
var colliders = new ClothSphereColliderPair[1];
colliders[1] = new ClothSphereColliderPair(SphereGoon.GetComponent<SphereCollider>());
a.sphereColliders = colliders;
}
}
The "monster" has a spherecollider attached to it.
Your answer
Follow this Question
Related Questions
Cloth physics on a rigged character 1 Answer
Issue with simulating cloth in Unity 2D 0 Answers
Mesh Collider 0 Answers