how to tell what layer you collided with on unity code example
Example 1: unity check collider layer
function OnCollisionEnter(collision : Collision)
{
if (collision.collider.gameObject.layer == LayerMask.NameToLayer("LAYER_NAME"))
{
Debug.Log("Touched a rail");
}
}
Example 2: checking a gamobjects layer
if(gameObject.layer == LayerMask.NameToLayer("LAYER_NAME")){}