Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to creating a field of view for the camera I'm making for a game. It rotates around a circle for 180 degrees while the head moves accordingly. I'm going to bound the field of view within an isosceles triangle using the method described on this website.

The problem I'm having is that I don't know how I'm going to detect if the field of view has intersected with the character as seen in this link.

Any help with this would be greatly appreciated.


sorry I meant an asset in game representing a camera much like the enemy in the second link, not an actual camera class in XNA(really sorry)

share|improve this question
up vote 2 down vote accepted

Check out Linear Algebra for Game Developers

See the section titled Do Product. It has a tutorial for the math to determine whether an object is in the field of view of another object. Should get you started.

share|improve this answer
Thanks for that, this seems to be exactly what I'm looking for – dbomb101 Apr 7 '11 at 8:21

Check out the BoundingFrustum.Contains() function. You give it the view and projection and it builds the frustum. If you're going 2d, then you can add bounding boxes to a custom sprite class - example is here.

Edit: Check here for two different techniques for determining if a point is inside a triangle.

I think the bounding frustum could still work, but might be a bit more work. You can use the BoundingFrustum for things other than cameras. Each NPC would have to have a local view and projection to get their frustum and you can use that to check against a Vector3 (just set Z = 0 for Vector2). If you wanted to draw the frustum for debugging, you can get the points of the box and project them back to 2D just by setting the Z to 0.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.