This project has moved. For the latest updates, please go here.


Nov 15, 2008 at 9:58 AM
Edited Nov 15, 2008 at 10:01 AM
Hi, is there anyway to do a traceline type check to see if any bodies are in a line of sight? To basically see if anything is blocking the positions of one object from another. I am trying to have AI in my game tell if the player is hiding behind a physical body or not, and I am not sure how to check for this.
I am guessing I'll have to do this manually, but I am wondering if Farseer physics has anything to make this easier
Nov 15, 2008 at 12:43 PM
It depends.

If you have a 2D side scroller game where an object is going towards a point, but gets blocked by something, then there are 100 ways of doing it, depending on what you want. It could be as simple as just checking if the position of the object moving is changing over time. If it's not, it's blocked.

But if you really want to use "line of sight" you can create an AABB from the players "face" (It should have the height of the placers face) towards the edge of the screen. Then you check on every update if any of the other objects are intersecting this AABB.
Nov 18, 2008 at 3:51 PM
It sounds like he wants to check if there are any geometries between point A and point B.  I don't think an axis-aligned box would work for this if the two points aren't aligned on an axis.
Nov 18, 2008 at 5:03 PM
I think what Vermeulen wants is a ray trace check. This might make it into 2.1, but for now you'll have to find your own solution.