I want to have constant distance at which the raycasting should stop, but script ignore distance parameter. Help me please. Thank in advance.
void Update()
{
float distance = 0.3f;
Vector2 myvec = transform.position + target.position;
RaycastHit2D hit = Physics2D.Raycast(transform.position, -myvec,distance);
Debug.DrawRay(transform.position, -myvec, Color.yellow);
if (hit.collider != null)
{
print("hitted");
if(hit.collider.gameObject.CompareTag("earth"))
print("hit");
}
}