Here's the deal... There is a cube and a sphere, the sphere its a "component" (attached, i dont know how to say =(... ) of the cube. I want to use the collider of the sphere to destroy the cube, how can i do it?
It sounds like the sphere is a child of the cube (Components show up in the inspector when a GameObject is selected, children show up when you expand a GameObject in the hierarchy). To destroy the parent object, attach the following to your sphere:
function OnCollisionEnter (collision : Collision) {
GameObject.Destroy (transform.parent);
}
If you're using a non-trigger collider. If your sphere has a trigger collider ("Is Trigger" is checked in the inspector):
function OnTriggerEnter (other : Collider) {
GameObject.Destroy (transform.parent);
}
Be sure to check out the collision matrix at the bottom of this page to ensure that your collision/trigger messages get called.