how to make colliders only collide with specific other objects unity code example
Example: how to make colliders collide with some things but not other in unity
//ignores all collisions between the object collided with and the
//gameobject that this script is attached to
Physics.IgnoreCollision(
collision.gameObject.GetComponent<SphereCollider>(),
gameObject.GetComponent<SphereCollider>());