Linecast not detecting object on default layer

I have a game where i need my enemy to detect if there are any walls between it and the player. both the enemy and the object in between are in the default layer, but the raycast is never returns a different value.
I have drawn a line with the same input coordinates to ensure that the linecast is passing through the object. the object in between also has a collider and a rigidbody. What are some possible reasons the linecast isn’t detecting the object

here is the code. it is being done inside a triggerEnter.

Debug.Log(Physics.Linecast (other.transform.position, transform.position));
if (Physics.Linecast (transform.position, other.transform.position)) 
Debug.DrawLine(transform.position, other.transform.position,,10);

this image shows the enemy, the object in the middle, and the player with the raycast drawn in between

Hi @Cosmey. Could it be because you have issued a Physics.Linecast and not a Physics2D.Linecast?