how to make sertain objects not collide with each other unity code example

Example 1: unity how to make two objects not collide

void OnCollisionEnter(Collision collision)
  {
      if (collision.gameObject.tag == "theobjectToIgnore")
      {
          Physics.IgnoreCollision(theobjectToIgnore.collider, collider);
      }

Example 2: how to make sertain objects not collide with each other unity

Create a new layer called "Enemies" and have it
be the layer of all your enemy gameobjects. Then
take a look at the Physics Layers settings under
Edit/Project Settings/Physics, 
and disable collisions for objects 
in the Enemies layer with other 
objects in that same layer.

Tags:

Misc Example