A problem with triggers

Hey ,
I’m trying to make an object disappear when the character run to it . I tried to use the function OnTriggerEnter. It goes like that:

void OnTriggerEnter(Collider invisible ) {
Destroy(invisible.gameObject);
}

and i also tried to use GameObject.Destroy(invisible);
nothing seems to work , any idea why ?

public int characterLayer = 10; // change this value according your character layer 

void OnTriggerEnter(Collider _collider)
{
	if (_collider.gameObject.layer == characterLayer)
	{
		Destroy(gameObject); // This will destroy the current gameObject where this script is attached, if you only want to dissapear this object just disable their renderer instead of destroying
	}
}

And attach a collider with Trigger enabled on this gameObject.

Hey ,
Thanks for replying, I tried your solution but it didn’t work .
Is there anything else i can do ?

This works.

How did you setup your gameObject?
Are you missing a collider with trigger marked?
Did you changed the layer value?

If you don’t want to use layers, just remove that if and check if the object is destroyed.

It worked without the if , thank you so much.