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;
}