Collider not working,Objects Not Colliding

I have 2D game where a player runs along the x axis and tries to hit or avoid falling objects. There are box colliders and rigidbodies on the player and the prefab falling objects. The Is Trigger box is checked on the player’s box collider. I have the following code on the player:

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

The objects just pass through the player and it seems no collision is occurring. I have read several responses to similar questions, but nothing seems to work. Please let me know if you have any suggestions.,I have a player that runs along the x axis and tries to collect and avoid falling objects. The player and the prefab falling objects all have box colliders and rigidbodies. On the players collider Is Trigger is checked. I put the following code on the player:

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

The objects that fall pass through the player. I have read several answers to similar questions, but nothing seems to fix this. Any suggestions?

If my guess is correct you’re using Rigidbody2D and OnTriggerEnter only works with 3D rigidbodies. If you change the OnTriggerEnter to OnTriggerEnter2D it should work with Rigidbody2D.

Be sure to “override” all changes (including the added script) in the prefabs.