Query (kind of)

I have a player and must find out if any obstacles are between the player and his target. Basically I would like to send out a "ray" to the target and see if it hits anything on the way.

Right now I am attempting to draw a thin box ("ray") between the player and the target. When I run through all the contacts later I could check for collisions with the ray.

I was wondering if there is any better way to do this in box2D? An aabb query would not have rotation and therefor would not really be a ray. Any suggestions?
There's really no substitute for a ray cast in this case. In 2.0 you'll be able to ray cast against shapes. You'll need to do an AABB query first to get all the shapes. 2.1 will have full ray cast functionality.
@galaktor:

I haven't tried this, but I would think maybe you could use a rectangular sensor for this. The only thing is I believe you would have to create the sensor on one step, and then wait until the next step to check the contacts. This may not be the most efficient way, but it might work.
Welll my version with the thin box as a ray is working, and it's not really killing my framerate either, so I'll just go with this variant and wait vor version 2.1 😉
I use flash version of Box2D (1.4.3). To check objects on a way of the character of game I do how it is shown in a picture.
Attachment:
111.jpg
111.jpg [ 33.56 KiB | Viewed 275 times ]

That is a lot of Querys, and it kill my framerate.


How it is possible to do it easier?
Galaktor, you can tell about " version with the thin box as a ray "?

Original thread: https://box2d.org/forum/viewtopic.php?t=340