Line of sight question.

Topics: Developer Forum
Dec 6, 2009 at 3:41 PM
Edited Dec 6, 2009 at 3:43 PM

Hello again. I'm currently trying to implement some AI for my project and I've stumbled upon a problem.

I'm using the rayhelper and the method LineSegmentAllGeomsIntersect() (I'm going to use LineSegmentGeomIntersect() later). I store the last geomPointPair from the list in my own list (since i'm using more lines for the enemy to check with), to get the geom closest to the enemy, and calculate out the closest point(vector). For some reason, when the player-geom is intersecting with the line too, it chooses that the player is the closest geom, no matter what. What I'm asking is why this is? How come only the player-geom does this, is there some kind of variable i've changed that creates this behavior? I've tried to change the collisiongroup but that didn't change anything, and I don't think it should either.

Anyway, a picture describes best: http://img13.imageshack.us/img13/2618/enemylinesight.th.jpg

Sorry, I don't know why it resizes.

Also, what is the difference between collisiongroup and collisioncategory?

Coordinator
Dec 6, 2009 at 4:21 PM

The RayHelper does not respect the collisiongroup or other collisionfiltering. You will have to check if it collides with the player geometry and ignore the ray hit.

The CollisionGroup and CollisionCategory properties are described here.

Dec 6, 2009 at 8:16 PM
genbox wrote:

The RayHelper does not respect the collisiongroup or other collisionfiltering. You will have to check if it collides with the player geometry and ignore the ray hit.

The CollisionGroup and CollisionCategory properties are described here.

Yes, I kind of understood that it didn't. And okay, I know how to check that, but my question is how it chooses the player as the closest colliding geometry when there clearly is something else much closer to the enemy. The problem might be solved temporarily by excluding the player geometry, but it might happen with another geometry again when I add more.

I don't know if I made the question any clearer, but I hope so.

Dec 10, 2009 at 8:52 PM

Please, any ideas on why this occurs only with the player? It feels wrong to assume that it's just the player that is the problem, but maybe it is...

I've got another question too. Can I calculate how far an object does travel in pixels/second or something like that? Is the applyforce/impulse and so on measured in pixels/second or something like that perhaps? Because it would be great if I could measure if an enemy can jump a certain height to get up to a platform, as an example.

Dec 10, 2009 at 9:46 PM
Edited Dec 10, 2009 at 9:47 PM
KazeN wrote:

I store the last geomPointPair from the list in my own list (since i'm using more lines for the enemy to check with), to get the geom closest to the enemy, and calculate out the closest point(vector).

As far as I know, the closest (or farthest) geometry is not necessary the last GeomPointPair in the list. I think they are not ordered by distance.

Dec 12, 2009 at 10:01 PM

Yeah I guess you're right. I just kind of hoped it did, since it would be quicker than to have me do it "manually" by checking each point for each pointpair. Anyway, it works now(when I check "manually", At least it seems to do that, and I'm going to assume it does ^^

So, Anyone have any Ideas about my other question? If I can calculate the height (in pixels) the enemy can jump for instance, given a certain impulse and such. Or how far (in pixels) the enemy travels each update and things like that. It would help incredibly.

And how do you create a platform-like box? you know, where you can jump up through from under it, and land on it?

Dec 13, 2009 at 12:12 AM

For calculating the height the enemy jumps given a certain impulse, you can use this:

vulgivagus' answer

The platform-like box you mention, has been addressed before here, I can't find the thread though, but basiaclly you check in the box's oncollision method the normal of the collision contact point, this way you will know if the characters arrives from above or from below, and then apply the collision or not.