Remove Box collider of object in unity 3d

Sona Rijesh picture Sona Rijesh · Feb 15, 2013 · Viewed 13.5k times · Source

Here is my code in Update function. The object has a box collider.

if (Input.GetMouseButtonDown(0)) { 
    Ray ray = camera.ScreenPointToRay(Input.mousePosition); 
    if (Physics.Raycast (ray, out hit3, 400.0F)) {
        wName = hit3.collider.gameObject.name;
        Destroy(hit3.collider.gameObject);
    }
}

But the box collider is not getting destroyed.

How can I destroy it?

Answer

Sona Rijesh picture Sona Rijesh · Feb 15, 2013

Its working now with code

 Destroy(hit3.collider);