I am making a 2d top down shooter and i need to tell what the tag of the object that I hit. I have this:
RaycastHit2D hit = Physics2D.Raycast(transform.position, transform.right, range, canShoot);
if (hit != null)
{
print ("Hit Something");
}
I put in hit.collider.tag but it gives me an error and doesnt work.