Security Cam like Splinter Cell

Hi,
I am developing a game wherein I require security cameras which trigger an alarm once the player enters its view range. Please do not mistake these for the Unity Camera objects. The closest example to what I am trying to develop are the cameras in the SplinterCell series of games.
How do I create the cone of sight for the security cam? Unity does not have any cone primitive and non-uniform scaling is not recommended.

Thanks,
Preet

Well, even if you could make a cone primitive for view field, I wouldn’t recommend it. Try doing something like this (C# code, to be put on the camera):

public float cameraAngle;
public float viewDistance;

public bool CheckCanSee(Transform canISeeThis)
{
    Vector3 direction = canISeeThis.position - transform.position;
    if(direction.magnitude > viewDistance)
    {
        // The target is too far away to see!
        return false;
    }
    if(Vector3.Angle(direction, transform.forward) > cameraAngle)
    {
        // The target is outside the field of view!
        return false;
    }
    if(Physics.Linecast(transform.position, canISeeThis.position))
    {
        // There's something in the way! I can't see it!
        return false;
    }
    // If I've gotten to here, the target is in range,
    // within the field of view, and not obscured.

    return true;
}

(There are a few clever things you can do to make the camera more intelligent- mainly to do with the part about whether the target object is obscured. However, for most simple situations this works perfectly well!)

To use this, put that script on your camera. The camera can move however you like, and then to find out whether it can see a given transform at any point in time, use

if(securityCam.CheckCanSee(playerTransform))
{
    // It can see me! Oh no!
}

where ‘securityCam’ is a reference to one of the cameras.

There was already a question about how to create the exact view frustum as mesh to be able to visualize the view area of a camera.