Collision Layers In Unity

In addition to filtering by things like Tags, Unity can use Layers to categorize which GameObjects should interact with one another. This is an easy way to make sure things like your UI aren’t affected by your gameplay objects, but you can also use Layers to classify objects separately if you know you never want them to interact.

Unity provides a few layers by default, but it supports up to 32 in total

Once you have your layers configured, you can set their interaction rules in the Physics section of your project settings.

Note that Physics and Physics 2D rules are separate

With these properties defined, all that’s left to do is set the layer on each of your game objects. There are of course more features related to layers, but even this much gives you basic exclusion, which is often all you really need.