Make a certain object not collide with a certain object

Hi!

So I have this 2D game and I want the bullets to not collide with terrain walls. They should get destroyed when they touch it but I can’t get them destroyed. Any help?

I also have this script I made to try and destroy them.

function OnCollisionEnter (bullet : Collision)
{
	if(bullet.gameObject.name == "Bullet(Clone)"){
		Destroy(bullet.gameObject);
	}
}

You can assign objects to physics layers.

Then use the Layer Collision Matrix of the Physics Manager to control which layers can interact with each other.

This also has the advantage of optimizing your collision checks, so your game should run faster.

you don’t need to add (Clone) to the prefab name. also, you can assign TAG and then use bullet.comparetag(“bullet”). check this: Unity - Scripting API: Component.CompareTag

or, like already told, use layers…