unity 2d how to check layer collision 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");
}
}