0 Favourites

# Field of Vision Mathematics Help

This forum is currently in read-only mode.
• 6 posts
• Say, I wanted to make a stealth game for a contest and I wanted to clone the way MGS1 handles FOV for enemies.

So basically every enemy has a pie-shaped FOV. When the player crosses that, he blows his cover and will be chased down by enemies.

The problem is how to make that pie shape. If it's 360FOV(basically a circle), it's easy to compute using distance formula, but with a pie(fraction of a circle), I'm not sure how the formula will go. Help?

• Pie-shaped detector sprite with containers?

• Just use the line of sight behavior, that has the field of vision (angle range) that you're wanting, and distance it can see.

• Keep in mind distance(x,y,xx,yy) works off of hotspots, so the distance is basically half the radius of the circular field of vision. So distance() will give you 360 degrees regardless.

• You can do this by "drawing" a line to each object within range and checking if it overlaps any solids. If you want a partial visibility, you can draw two lines instead - from the observer to edges of the target's bounding box to form a cone. If one line is obstructed but other is not, the target is partially visible.

Though overlapping and collision tests are CPU intensive. I believe a raytracing plugin would be a better option to reduce the overhead. There is Line of Sight plugin, for one.

If you want to simulate a Field of View effect - an overlay, a flickering torch or whatever - that is another story altogether. You want to draw a polygon that is limited by obstacles, this would be difficult to replicate in Construct.

It would be much easier if you had an "obstacle map" and used a certain pathfinding/flow algorithm to fill the area around player, then use this data to draw the Field of Vision.