How to determine which gameObject your collider collides with?

I am trying to make it so that when my player collides with an item, the item is destroyed, My player gameObject has a collider and a rigibody and the item has a collider. I am using the OnTriggerEnter and i have is trigger enabled. However I am not sure how to reference which item I am hitting. Is there a way too specify the game object that you collided with?

 void OnTriggerEnter2D(Collider2D player)
    {

        Destroy();
    }

Check out the docs

Also look up “CompareTag” if you want to use tags.

First Use a tag to indicate the object. For example your player is tagged as “Hero”

void OnTriggerEnter2D(Collider2D other)

{

if(other.tag == “Hero // tag name of the object//”)

{

destroy(gameobject);

}

}
//attach the script to the object whih the player will collide

void OnTriggerEnter(Collider other)
{
//Take your pick!
if (other.gameObject.name == “Whatever”) Destroy(other.gameObject);
if (other.gameObject.name.Contains(“whatever”)) Destroy(other.gameObject);
if (other.tag == “Whatever”) Destroy(other.gameObject);
}