Hi there
I am not sure whether to put this here or in the games development section I do apologies if it is in the wrong the section.

I have an object with a bounding box around it. I want another object to then be able to send a ray out and test to see if the box is within a given range.

I would also like the object generating the ray to be able to constantly change the direction of the ray.

Is there a simple formula that I am missing for doing ray-AABB intersection? I have read about splitting a box into "slabs"?

This seems unnecessary for what I am trying to achieve I simply want to fire a ray and see if it intersects with a box, and at what distance.

Any help would be greatly appreciated

6 Years
Discussion Span
Last Post by eskimo456

Your ray is technically a line, as is the edge of the bounding box. Check if they intersect and where. Then check if the intersection point is within the segment that is the edge of the bounding box. If it is, use the distance between two points formula to find the distance.


Awesome many thanks got it working now.

Annoyingly easy when you know how :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.