unity raycast all layers except one
Code Example - unity raycast all layers except one
RaycastHit hit = Physics2D.Raycast(position, direction,
range, ~(1 << LayerMask.NameToLayer("Player"))))