# Determining whether an object is in field of view considering obstacles

I'm thinking of stealth games where an object has a certain field of view that you want to avoid otherwise game over.

The field of view may be linear or circular or any arbitrary group of pixels/tiles.

If I don't consider obstacles (for example, if you're standing behind a wall, they can still see you), I can determine whether the player is within an object's field of view using simple geometric properties using the two object's positions and range. This can be done efficiently, though it kind of assumes the objects are points.

However, to make it realistic, you should be able to hide behind a wall or a tree without being seen.

How is this problem usually solved?
What are some articles that I can read to understand more about this problem?

## 1 Answer

Basically, you're going to be doing raycasting to figure out where exactly the vision gets blocked. The complexities come in with trying to make that clean and efficient and fit with how you're managing the actual scene. Other people have done a much better job explaining everything than I can, so I'm just going to reference them.

Amit has a fantastic overview here, and there's another great one here. For the second, there's also some relevant discussion here. Note that these are for 2D games, but the concepts are still the same for 3D.

• Briefly looked at the visibility-related articles and look pretty good so far (with nice images as well). I'm focused on 2D at the moment so this would be perfect. Commented Mar 25, 2014 at 18:08