0 Favourites

Field of Vision Mathematics Help

This forum is currently in read-only mode.
  • 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.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • The way I plan to handle obstacles is that after it confirms that the player is withing range, have it check for an 'obstacle' across the line of sight. I will keep it simple and just use the sprite holder(collision box) of the player to be checked and not the actual sprite,and make use of certain stances(stand, crouch,crawl) to be tested against the obstacles and will give a fake partial visibility testing.

    I haven't tried the Line of Sight Behavior - I think I should have before posting this - but I like itt to be flexible so I try to make my own functions as possible.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)