How to remove a parents boxcollider2d?

In my project i wanted to remove the boxcollider of the parent from the object where the script is attached to. How can i do that? I know how to remove a boxcollider, but not how i do this.

Is it something like this that you’re looking for?

void RemoveParentCollider()
{
    Transform parentTransform = transform.parent;
    if (parentTransform  == null)
        return; // no parent

    BoxCollider2D parentCollider = parentTransform.GetComponent<BoxCollider2D>();
    if (parentCollider)
        DestroyImmediate(parentCollider);
}

Hi. try that…

//child is your gameobject
Component.Destroy( child.GetComponentInParent<BoxCollider2D> ());
		//or
child.GetComponentInParent<BoxCollider2D> ().enabled = false;

Get the parent game object by transform.parent and assign to a game object obj and Destroy(obj.get component() )

Thanks, that is what im looking for