Checking to see if an object is in front of another object?

I’m trying to check if an object (player) is in front of another object (enemy). I think the best way to do this would be to use the Quaternion class to find the angle of the enemy, and if the player is within the 180 degree view in the direction its facing then I make a boolean seesTarget true. Would this work? Unfortunately, I don’t know exactly how to check all the angles for this, could someone help me out?

The example code is exactly what you need.

if (transform.InverseTransformPoint(otherTransform.position).z > 0.0)
    print ("object is in front");

–Eric