Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove Box collider of object in unity 3d

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?

like image 381
Sona Rijesh Avatar asked Feb 15 '13 05:02

Sona Rijesh


1 Answers

Its working now with code

 Destroy(hit3.collider);
like image 188
Sona Rijesh Avatar answered Sep 25 '22 04:09

Sona Rijesh