Draw a ray to deterime if anything is in front of colliding object?

I have a security camera and a collider attached to the detection area. I want the script to detect that the colliding object is a player, and then using a raycast to determine if the player is behind one of the two ledges they can hide behind.


How can I do this? I believe I would have to find the position of the camera and for the origin point, but how can I determine the direction (the camera moves side to side 45 degrees) and length to send the ray?

My script is currently:
import UnityEngine

class detection_script (MonoBehaviour): 

	def Start ():
	def FixedUpdate ():
	def OnTriggerStay(collisionInfo as Collider):
		if collisionInfo.collider.tag == "Player":

Here is an example on the Unity references.

Attach a script to the camera itself and use the direction of the camera to determine where the Ray is pointing.

using UnityEngine;
using System.Collections;

public class Example : MonoBehaviour {
    void Update() {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;
        if (Physics.Raycast(ray, out hit, 100))
            Debug.DrawLine(ray.origin, hit.point);

// C# Code

public float distance;

RaycastHit hit;

if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit))


   distance = hit.distance;
   // now you now how far away you are from an object. With the hit variable you basically have a pointer to game object.