- Home /
This question was
closed Jan 16, 2020 at 09:40 PM by
ItArth.
Question by
ItArth · Jan 16, 2020 at 09:32 PM ·
scripting problembeginnercloth
Found Spheres Colliders and add it to cloth spheres colliders
I whant a script that find spheres colliders in all the scene and then add to the cloth spheres colliders I am trying this but I get an error;I am Beginner. I am trying this script:
private Cloth cloth;
public SphereCollider[] colliders;
void Start()
{
cloth = GetComponent<Cloth>();
colliders = FindObjectsOfType<SphereCollider>();
}
void Update()
{
if (colliders != null)
{
colliders = cloth.sphereColliders; //This line give me an error :(
}
}
collider.png
(13.5 kB)
Comment
Answer by Esteem · Jan 16, 2020 at 09:36 PM
you're not adding colliders to cloth.sphereColliders as per your question from the header.
instead of this:
colliders = cloth.sphereColliders;
do this:
cloth.sphereColliders = colliders;