Trying to detect if the mouse has passed over two colliders is not working unless the mouse is moved slowly. If the mouse is moved at speed, only the first collision is detected.
Any ideas?
if (Input.GetMouseButton(0))
{
RaycastHit2D hit = Physics2D.Raycast(mainCamera.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
if (hit)
{
if (hit.collider.tag == "validTag")
{
if (firstCollider = null)
{
Debug.Log("Hit First Collider");
firstCollider = hit.collider;
}
else
{
if (hit.collider != firstCollider)
{
Debug.Log("Hit Second");i
}
}
}
}
}