# RayCast seems to ignore some objects?

I'm currently using a Raycast both for my movement check aswell as a focus-setting check, both checks use pretty much the same code. The problem i'm having is that the Raycast goes through some objects and targets the background no matter what i've tried to far. As you can see in this screenshot, I first clicked on the black sphere (Just a 3D Sphere in my 2D world with a default Sphere Collider) and the Log shows so aswell, however when i click on the white box which the second Debug Log is supposed to be, it just ignores the box collider and goes straight to the Background (the green sprite). The same problem with the Interactable check, code works completely fine with the Sphere but not with the box. Here's the Code i currently use:

    //Movement
if (Input.GetKeyDown(KeyCode.Mouse0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;

if (Physics.Raycast(ray, out hit, 100))
{
Debug.Log("We hit " + hit.collider.name + " " + hit.point);
RemoveFocus();
targetPosition = hit.point;
}
}
if(targetPosition != (Vector2)transform.position)
transform.position = Vector3.MoveTowards(transform.position, targetPosition, maxSpeed * Time.deltaTime);

//Check for Interactable, pretty much same code...
if (Input.GetKeyDown(KeyCode.Mouse1))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;

if (Physics.Raycast(ray, out hit, 200))
{
Interactable interactable = hit.collider.GetComponent<Interactable>();
if(interactable != null)
{
SetFocus(interactable);
}
}
}

• Is your 2D stuff sprites, or UI? Does your 2D stuff use Physics2D? docs.unity3d.com/ScriptReference/Physics2D.Raycast.html – MichaelHouse May 1 '18 at 2:29
• A screenshot to the components of the white box is in the text, here is the sphere which works as i intend it to. – Veineless May 1 '18 at 3:01
• I've tried playing around with different colliders on the white box, using 3d and 2d colliders etc however nothing seemed to fix the issue, not really sure where to look anymore :( – Veineless May 1 '18 at 3:14