unity raycast2d not working code example
Example: why raycast is not hitting a 2d object unity
//Have to use 2D version in 2D scenes.
//Object must have a collider.
RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.down);
if ((hit.collider != null) && (Input.GetMouseButtonDown (0)))
{
print ("This hit at " + hit.collider.name);
}