unity check if colliding with layer code example
Example: unity check collider layer
function OnCollisionEnter(collision : Collision)
{
if (collision.collider.gameObject.layer == LayerMask.NameToLayer("LAYER_NAME"))
{
Debug.Log("Touched a rail");
}
}