Physics.Raycast issue | Ray not casting at certain angles?

So i am creating a camera orbit script right now and want to detect if anything is between the player and the camera.

For some reason, the ray is only getting cast when the camera is in front of the player and not behind him at an angle.

Here is my code along with some screenshots to the issue:

IN FRONT OF THE PLAYER

BEHIND THE PLAYER

You can see that the debug line is not even being drawn at that angle for some reason.

RaycastHit hit;
Ray ray = new Ray(RaycastOrigin.transform.position, RaycastTarget.transform.position);
       
if (Physics.Raycast(ray, out hit))
{
RaycastObstacle = hit.transform.gameObject;
Debug.DrawLine(RaycastOrigin.transform.position, RaycastTarget.transform.position, Color.red);
value = RaycastObstacle;
}

Common mistake: a raycast takes a starting point and a direction not an ending point. Either use LineCast which takes ending point instead, or calculate direction:

Vectror3 rayDirection = RaycastTarget.transform.position - RaycastOrigin.transform.position;
Ray ray = new Ray(RaycastOrigin.transform.position, rayDirection);